From 1a75ba3c67cf68eeea4db1e430de28d50a974ab9 Mon Sep 17 00:00:00 2001 From: Ashok Menon Date: Tue, 1 Nov 2016 10:14:05 -0700 Subject: [PATCH] Expose BC version Reviewed By: javache Differential Revision: D4110361 fbshipit-source-id: 6cde7d8ca26d30a804f1a99cf9380dcbc0ff5541 --- React/Executors/RCTJSCWrapper.h | 8 ++++++++ React/Executors/RCTJSCWrapper.mm | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/React/Executors/RCTJSCWrapper.h b/React/Executors/RCTJSCWrapper.h index 68ddb46c17b..e112320cbc3 100644 --- a/React/Executors/RCTJSCWrapper.h +++ b/React/Executors/RCTJSCWrapper.h @@ -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; diff --git a/React/Executors/RCTJSCWrapper.mm b/React/Executors/RCTJSCWrapper.mm index d7d3c95d337..625d430a6cb 100644 --- a/React/Executors/RCTJSCWrapper.mm +++ b/React/Executors/RCTJSCWrapper.mm @@ -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"), };