mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-22 20:41:18 +00:00
Merge pull request #136 from realm/al-version
Support RectNative version 0.14
This commit is contained in:
commit
8e9a14e1c0
@ -14,8 +14,8 @@ extern "C" {
|
||||
#import <GCDWebServers/GCDWebServers.h>
|
||||
#endif
|
||||
|
||||
@interface NSObject (RCTJavaScriptContext)
|
||||
- (instancetype)initWithJSContext:(JSGlobalContextRef)context;
|
||||
@interface NSObject ()
|
||||
- (instancetype)initWithJSContext:(void *)context;
|
||||
- (JSGlobalContextRef)ctx;
|
||||
@end
|
||||
|
||||
@ -25,19 +25,25 @@ JSGlobalContextRef RealmReactGetJSGlobalContextForExecutor(id executor, bool cre
|
||||
return NULL;
|
||||
}
|
||||
|
||||
id rctJSContext = contextIvar ? object_getIvar(executor, contextIvar) : nil;
|
||||
id rctJSContext = object_getIvar(executor, contextIvar);
|
||||
if (!rctJSContext && create) {
|
||||
Class RCTJavaScriptContext = NSClassFromString(@"RCTJavaScriptContext");
|
||||
if (RCTJavaScriptContext) {
|
||||
JSGlobalContextRef ctx = JSGlobalContextCreate(NULL);
|
||||
rctJSContext = [[RCTJavaScriptContext alloc] initWithJSContext:ctx];
|
||||
object_setIvar(executor, contextIvar, rctJSContext);
|
||||
NSMethodSignature *signature = [RCTJavaScriptContext instanceMethodSignatureForSelector:@selector(initWithJSContext:)];
|
||||
assert(signature);
|
||||
|
||||
// React Native 0.14+ expects a JSContext here, but we also support 0.13.x, which takes a JSGlobalContextRef.
|
||||
if (!strcmp([signature getArgumentTypeAtIndex:2], "@")) {
|
||||
JSContext *context = [[JSContext alloc] init];
|
||||
rctJSContext = [[RCTJavaScriptContext alloc] initWithJSContext:(void *)context];
|
||||
}
|
||||
else {
|
||||
NSLog(@"Failed to load RCTJavaScriptContext class");
|
||||
JSGlobalContextRef ctx = JSGlobalContextCreate(NULL);
|
||||
rctJSContext = [[RCTJavaScriptContext alloc] initWithJSContext:ctx];
|
||||
}
|
||||
|
||||
object_setIvar(executor, contextIvar, rctJSContext);
|
||||
}
|
||||
|
||||
|
||||
return [rctJSContext ctx];
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
"start": "node_modules/react-native/packager/packager.sh"
|
||||
},
|
||||
"dependencies": {
|
||||
"react-native": "0.13.2",
|
||||
"react-native": "0.14.2",
|
||||
"realm": "file:../../lib"
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
"start": "node_modules/react-native/packager/packager.sh"
|
||||
},
|
||||
"dependencies": {
|
||||
"react-native": "0.13.2",
|
||||
"react-native": "0.14.2",
|
||||
"realm": "file:../../lib",
|
||||
"realm-tests": "file:.."
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user