Expose BC version

Reviewed By: javache

Differential Revision: D4110361

fbshipit-source-id: 6cde7d8ca26d30a804f1a99cf9380dcbc0ff5541
This commit is contained in:
Ashok Menon 2016-11-01 10:14:05 -07:00 committed by Facebook Github Bot
parent ace32e650c
commit 1a75ba3c67
2 changed files with 12 additions and 0 deletions

View File

@ -27,6 +27,13 @@ typedef bool (*JSValueIsNullFuncType)(JSContextRef, JSValueRef);
typedef JSValueRef (*JSEvaluateScriptFuncType)(JSContextRef, JSStringRef, JSObjectRef, JSStringRef, int, JSValueRef *);
typedef JSValueRef (*JSEvaluateBytecodeBundleFuncType)(JSContextRef, JSObjectRef, int, JSStringRef, JSValueRef *);
/**
* JSNoBytecodeFileFormatVersion
*
* Version number indicating that bytecode is not supported by this runtime.
*/
extern const int32_t JSNoBytecodeFileFormatVersion;
typedef struct RCTJSCWrapper {
JSStringCreateWithCFStringFuncType JSStringCreateWithCFString;
JSStringCreateWithUTF8CStringFuncType JSStringCreateWithUTF8CString;
@ -43,6 +50,7 @@ typedef struct RCTJSCWrapper {
JSValueIsNullFuncType JSValueIsNull;
JSEvaluateScriptFuncType JSEvaluateScript;
JSEvaluateBytecodeBundleFuncType JSEvaluateBytecodeBundle;
const int32_t JSBytecodeFileFormatVersion;
Class JSContext;
Class JSValue;
} RCTJSCWrapper;

View File

@ -41,6 +41,8 @@ static void *RCTCustomLibraryHandler(void)
return handler;
}
const int32_t JSNoBytecodeFileFormatVersion = -1;
static RCTJSCWrapper *RCTSetUpSystemLibraryPointers()
{
return new RCTJSCWrapper {
@ -59,6 +61,7 @@ static RCTJSCWrapper *RCTSetUpSystemLibraryPointers()
.JSValueIsNull = JSValueIsNull,
.JSEvaluateScript = JSEvaluateScript,
.JSEvaluateBytecodeBundle = NULL,
.JSBytecodeFileFormatVersion = JSNoBytecodeFileFormatVersion,
.JSContext = [JSContext class],
.JSValue = [JSValue class],
};
@ -87,6 +90,7 @@ static RCTJSCWrapper *RCTSetUpCustomLibraryPointers()
.JSValueIsNull = (JSValueIsNullFuncType)dlsym(libraryHandle, "JSValueIsNull"),
.JSEvaluateScript = (JSEvaluateScriptFuncType)dlsym(libraryHandle, "JSEvaluateScript"),
.JSEvaluateBytecodeBundle = (JSEvaluateBytecodeBundleFuncType)dlsym(libraryHandle, "JSEvaluateBytecodeBundle"),
.JSBytecodeFileFormatVersion = *(const int32_t *)dlsym(libraryHandle, "JSBytecodeFileFormatVersion"),
.JSContext = (__bridge Class)dlsym(libraryHandle, "OBJC_CLASS_$_JSContext"),
.JSValue = (__bridge Class)dlsym(libraryHandle, "OBJC_CLASS_$_JSValue"),
};