Add more functions to RCTJSCWrapper + make it a public header

Reviewed By: javache

Differential Revision: D4133936

fbshipit-source-id: 04951965099598f7058cb0005267712c276582b9
This commit is contained in:
Indragie Karunaratne 2016-11-14 08:59:20 -08:00 committed by Facebook Github Bot
parent 3a9a4fd33a
commit 13aba82a2b
2 changed files with 33 additions and 1 deletions

View File

@ -9,22 +9,30 @@
#import <JavaScriptCore/JavaScriptCore.h>
#import "RCTDefines.h"
#import <FBReactKit/RCTDefines.h>
typedef void (*voidWithNoParamsFuncType)();
typedef JSStringRef (*JSStringCreateWithCFStringFuncType)(CFStringRef);
typedef JSStringRef (*JSStringCreateWithUTF8CStringFuncType)(const char *);
typedef CFStringRef (*JSStringCopyCFStringFuncType)(CFAllocatorRef, JSStringRef);
typedef void (*JSStringReleaseFuncType)(JSStringRef);
typedef void (*JSGlobalContextSetNameFuncType)(JSGlobalContextRef, JSStringRef);
typedef void (*JSObjectSetPropertyFuncType)(JSContextRef, JSObjectRef, JSStringRef, JSValueRef, JSPropertyAttributes, JSValueRef *);
typedef JSObjectRef (*JSContextGetGlobalObjectFuncType)(JSContextRef);
typedef JSValueRef (*JSObjectGetPropertyFuncType)(JSContextRef, JSObjectRef, JSStringRef, JSValueRef *);
typedef bool (*JSObjectIsFunctionFuncType)(JSContextRef, JSObjectRef);
typedef bool (*JSObjectIsConstructorFuncType)(JSContextRef, JSObjectRef);
typedef JSPropertyNameArrayRef (*JSObjectCopyPropertyNamesFuncType)(JSContextRef, JSObjectRef);
typedef size_t (*JSPropertyNameArrayGetCountFuncType)(JSPropertyNameArrayRef);
typedef JSStringRef (*JSPropertyNameArrayGetNameAtIndexFuncType)(JSPropertyNameArrayRef, size_t);
typedef void (*JSPropertyNameArrayReleaseFuncType)(JSPropertyNameArrayRef);
typedef JSValueRef (*JSValueMakeFromJSONStringFuncType)(JSContextRef, JSStringRef);
typedef JSValueRef (*JSObjectCallAsFunctionFuncType)(JSContextRef, JSObjectRef, JSObjectRef, size_t, const JSValueRef *, JSValueRef *);
typedef JSValueRef (*JSValueMakeNullFuncType)(JSContextRef);
typedef JSStringRef (*JSValueCreateJSONStringFuncType)(JSContextRef, JSValueRef, unsigned, JSValueRef *);
typedef bool (*JSValueIsUndefinedFuncType)(JSContextRef, JSValueRef);
typedef bool (*JSValueIsNullFuncType)(JSContextRef, JSValueRef);
typedef JSObjectRef (*JSValueToObjectFuncType)(JSContextRef, JSValueRef, JSValueRef *);
typedef JSValueRef (*JSEvaluateScriptFuncType)(JSContextRef, JSStringRef, JSObjectRef, JSStringRef, int, JSValueRef *);
typedef JSValueRef (*JSEvaluateBytecodeBundleFuncType)(JSContextRef, JSObjectRef, int, JSStringRef, JSValueRef *);
@ -38,17 +46,25 @@ extern const int32_t JSNoBytecodeFileFormatVersion;
typedef struct RCTJSCWrapper {
JSStringCreateWithCFStringFuncType JSStringCreateWithCFString;
JSStringCreateWithUTF8CStringFuncType JSStringCreateWithUTF8CString;
JSStringCopyCFStringFuncType JSStringCopyCFString;
JSStringReleaseFuncType JSStringRelease;
JSGlobalContextSetNameFuncType JSGlobalContextSetName;
JSObjectSetPropertyFuncType JSObjectSetProperty;
JSContextGetGlobalObjectFuncType JSContextGetGlobalObject;
JSObjectGetPropertyFuncType JSObjectGetProperty;
JSObjectIsFunctionFuncType JSObjectIsFunction;
JSObjectIsConstructorFuncType JSObjectIsConstructor;
JSObjectCopyPropertyNamesFuncType JSObjectCopyPropertyNames;
JSPropertyNameArrayGetCountFuncType JSPropertyNameArrayGetCount;
JSPropertyNameArrayGetNameAtIndexFuncType JSPropertyNameArrayGetNameAtIndex;
JSPropertyNameArrayReleaseFuncType JSPropertyNameArrayRelease;
JSValueMakeFromJSONStringFuncType JSValueMakeFromJSONString;
JSObjectCallAsFunctionFuncType JSObjectCallAsFunction;
JSValueMakeNullFuncType JSValueMakeNull;
JSValueCreateJSONStringFuncType JSValueCreateJSONString;
JSValueIsUndefinedFuncType JSValueIsUndefined;
JSValueIsNullFuncType JSValueIsNull;
JSValueToObjectFuncType JSValueToObject;
JSEvaluateScriptFuncType JSEvaluateScript;
JSEvaluateBytecodeBundleFuncType JSEvaluateBytecodeBundle;
voidWithNoParamsFuncType configureJSCForIOS;

View File

@ -62,17 +62,25 @@ static RCTJSCWrapper *RCTSetUpSystemLibraryPointers()
return new RCTJSCWrapper {
.JSStringCreateWithCFString = JSStringCreateWithCFString,
.JSStringCreateWithUTF8CString = JSStringCreateWithUTF8CString,
.JSStringCopyCFString = JSStringCopyCFString,
.JSStringRelease = JSStringRelease,
.JSGlobalContextSetName = JSGlobalContextSetName,
.JSObjectSetProperty = JSObjectSetProperty,
.JSContextGetGlobalObject = JSContextGetGlobalObject,
.JSObjectGetProperty = JSObjectGetProperty,
.JSObjectIsFunction = JSObjectIsFunction,
.JSObjectIsConstructor = JSObjectIsConstructor,
.JSObjectCopyPropertyNames = JSObjectCopyPropertyNames,
.JSPropertyNameArrayGetCount = JSPropertyNameArrayGetCount,
.JSPropertyNameArrayGetNameAtIndex = JSPropertyNameArrayGetNameAtIndex,
.JSPropertyNameArrayRelease = JSPropertyNameArrayRelease,
.JSValueMakeFromJSONString = JSValueMakeFromJSONString,
.JSObjectCallAsFunction = JSObjectCallAsFunction,
.JSValueMakeNull = JSValueMakeNull,
.JSValueCreateJSONString = JSValueCreateJSONString,
.JSValueIsUndefined = JSValueIsUndefined,
.JSValueIsNull = JSValueIsNull,
.JSValueToObject = JSValueToObject,
.JSEvaluateScript = JSEvaluateScript,
.JSBytecodeFileFormatVersion = JSNoBytecodeFileFormatVersion,
.JSEvaluateBytecodeBundle = (JSEvaluateBytecodeBundleFuncType)UnimplementedJSEvaluateBytecodeBundle,
@ -92,17 +100,25 @@ static RCTJSCWrapper *RCTSetUpCustomLibraryPointers()
auto wrapper = new RCTJSCWrapper {
.JSStringCreateWithCFString = (JSStringCreateWithCFStringFuncType)dlsym(libraryHandle, "JSStringCreateWithCFString"),
.JSStringCreateWithUTF8CString = (JSStringCreateWithUTF8CStringFuncType)dlsym(libraryHandle, "JSStringCreateWithUTF8CString"),
.JSStringCopyCFString = (JSStringCopyCFStringFuncType)dlsym(libraryHandle, "JSStringCopyCFString"),
.JSStringRelease = (JSStringReleaseFuncType)dlsym(libraryHandle, "JSStringRelease"),
.JSGlobalContextSetName = (JSGlobalContextSetNameFuncType)dlsym(libraryHandle, "JSGlobalContextSetName"),
.JSObjectSetProperty = (JSObjectSetPropertyFuncType)dlsym(libraryHandle, "JSObjectSetProperty"),
.JSContextGetGlobalObject = (JSContextGetGlobalObjectFuncType)dlsym(libraryHandle, "JSContextGetGlobalObject"),
.JSObjectGetProperty = (JSObjectGetPropertyFuncType)dlsym(libraryHandle, "JSObjectGetProperty"),
.JSObjectIsFunction = (JSObjectIsFunctionFuncType)dlsym(libraryHandle, "JSObjectIsFunction"),
.JSObjectIsConstructor = (JSObjectIsConstructorFuncType)dlsym(libraryHandle, "JSObjectIsConstructor"),
.JSObjectCopyPropertyNames = (JSObjectCopyPropertyNamesFuncType)dlsym(libraryHandle, "JSObjectCopyPropertyNames"),
.JSPropertyNameArrayGetCount = (JSPropertyNameArrayGetCountFuncType)dlsym(libraryHandle, "JSPropertyNameArrayGetCount"),
.JSPropertyNameArrayGetNameAtIndex = (JSPropertyNameArrayGetNameAtIndexFuncType)dlsym(libraryHandle, "JSPropertyNameArrayGetNameAtIndex"),
.JSPropertyNameArrayRelease = (JSPropertyNameArrayReleaseFuncType)dlsym(libraryHandle, "JSPropertyNameArrayRelease"),
.JSValueMakeFromJSONString = (JSValueMakeFromJSONStringFuncType)dlsym(libraryHandle, "JSValueMakeFromJSONString"),
.JSObjectCallAsFunction = (JSObjectCallAsFunctionFuncType)dlsym(libraryHandle, "JSObjectCallAsFunction"),
.JSValueMakeNull = (JSValueMakeNullFuncType)dlsym(libraryHandle, "JSValueMakeNull"),
.JSValueCreateJSONString = (JSValueCreateJSONStringFuncType)dlsym(libraryHandle, "JSValueCreateJSONString"),
.JSValueIsUndefined = (JSValueIsUndefinedFuncType)dlsym(libraryHandle, "JSValueIsUndefined"),
.JSValueIsNull = (JSValueIsNullFuncType)dlsym(libraryHandle, "JSValueIsNull"),
.JSValueToObject = (JSValueToObjectFuncType)dlsym(libraryHandle, "JSValueToObject"),
.JSEvaluateScript = (JSEvaluateScriptFuncType)dlsym(libraryHandle, "JSEvaluateScript"),
.JSEvaluateBytecodeBundle = (JSEvaluateBytecodeBundleFuncType)dlsym(libraryHandle, "JSEvaluateBytecodeBundle"),
.configureJSCForIOS = (voidWithNoParamsFuncType)dlsym(libraryHandle, "configureJSCForIOS"),