mirror of
https://github.com/status-im/realm-js.git
synced 2025-02-02 09:46:28 +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>
|
#import <GCDWebServers/GCDWebServers.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@interface NSObject (RCTJavaScriptContext)
|
@interface NSObject ()
|
||||||
- (instancetype)initWithJSContext:(JSGlobalContextRef)context;
|
- (instancetype)initWithJSContext:(void *)context;
|
||||||
- (JSGlobalContextRef)ctx;
|
- (JSGlobalContextRef)ctx;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -25,17 +25,23 @@ JSGlobalContextRef RealmReactGetJSGlobalContextForExecutor(id executor, bool cre
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
id rctJSContext = contextIvar ? object_getIvar(executor, contextIvar) : nil;
|
id rctJSContext = object_getIvar(executor, contextIvar);
|
||||||
if (!rctJSContext && create) {
|
if (!rctJSContext && create) {
|
||||||
Class RCTJavaScriptContext = NSClassFromString(@"RCTJavaScriptContext");
|
Class RCTJavaScriptContext = NSClassFromString(@"RCTJavaScriptContext");
|
||||||
if (RCTJavaScriptContext) {
|
NSMethodSignature *signature = [RCTJavaScriptContext instanceMethodSignatureForSelector:@selector(initWithJSContext:)];
|
||||||
JSGlobalContextRef ctx = JSGlobalContextCreate(NULL);
|
assert(signature);
|
||||||
rctJSContext = [[RCTJavaScriptContext alloc] initWithJSContext:ctx];
|
|
||||||
object_setIvar(executor, contextIvar, rctJSContext);
|
// 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 {
|
else {
|
||||||
NSLog(@"Failed to load RCTJavaScriptContext class");
|
JSGlobalContextRef ctx = JSGlobalContextCreate(NULL);
|
||||||
|
rctJSContext = [[RCTJavaScriptContext alloc] initWithJSContext:ctx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object_setIvar(executor, contextIvar, rctJSContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [rctJSContext ctx];
|
return [rctJSContext ctx];
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
"start": "node_modules/react-native/packager/packager.sh"
|
"start": "node_modules/react-native/packager/packager.sh"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react-native": "0.13.2",
|
"react-native": "0.14.2",
|
||||||
"realm": "file:../../lib"
|
"realm": "file:../../lib"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
"start": "node_modules/react-native/packager/packager.sh"
|
"start": "node_modules/react-native/packager/packager.sh"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react-native": "0.13.2",
|
"react-native": "0.14.2",
|
||||||
"realm": "file:../../lib",
|
"realm": "file:../../lib",
|
||||||
"realm-tests": "file:.."
|
"realm-tests": "file:.."
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user