[jsc-dev] How to use JSExport and JavascriptCore in C++

Alexis Barra alexis.barra at gmail.com
Wed Oct 25 17:19:15 PDT 2017


I'm thinking on JavaScriptCore’s C API .. Do you have an idea how to tackle
it? I'm checking the API at this moment but I'm not clear how to use it.

On 25 October 2017 at 16:53, Geoffrey Garen <ggaren at apple.com> wrote:

> Hi Alexis.
>
> You’ll either need to convert your C++ objects to Objective-C objects,
> wrap your C++ objects in Objective-C objects, or use JavaScriptCore’s C API.
>
> Regards,
> Geoff
>
> On Oct 25, 2017, at 4:39 PM, Alexis Barra <alexis.barra at gmail.com> wrote:
>
> I'm working with JavascriptCore in a C++ project and I don't know how to
> expose a C++ class to javascript. For example in Objective-C is something
> like this:
>
> @protocol MyPointExports <JSExport>@property double x;@property double y;- (NSString *)description;- (instancetype)initWithX:(double)x y:(double)y;+ (MyPoint *)makePointWithX:(double)x y:(double)y;@end
> @interface MyPoint : NSObject <MyPointExports>- (void)myPrivateMethod;  // Not in the MyPointExports protocol, so not visible to JavaScript code. at end
> @implementation MyPoint// ... at end
> JSContext *context = [[JSContext alloc] init];
> // export MyPoint class
> context[@"MyPoint"] = [MyPoint class];
>
> But I have not idea how to translate JSExport and protocol into C++.
>
> --
> Alexis Barra.
>
> _______________________________________________
> jsc-dev mailing list
> jsc-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/jsc-dev
>
>
>


-- 
Alexis Barra.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/jsc-dev/attachments/20171025/17eb11f8/attachment-0001.html>


More information about the jsc-dev mailing list