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

Alexis Barra alexis.barra at gmail.com
Wed Oct 25 16:39:03 PDT 2017


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/jsc-dev/attachments/20171025/d0accb35/attachment-0001.html>


More information about the jsc-dev mailing list