Created
February 6, 2020 10:30
-
-
Save ozcanzaferayan/3ab345d4b828d09f48c4790fd669fde4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jsi::Value JSCRuntime::evaluateJavaScript( | |
const std::shared_ptr<const jsi::Buffer> &buffer, | |
const std::string &sourceURL) { | |
std::string tmp( | |
reinterpret_cast<const char *>(buffer->data()), buffer->size()); | |
JSStringRef sourceRef = JSStringCreateWithUTF8CString(tmp.c_str()); | |
JSStringRef sourceURLRef = nullptr; | |
if (!sourceURL.empty()) { | |
sourceURLRef = JSStringCreateWithUTF8CString(sourceURL.c_str()); | |
} | |
JSValueRef exc = nullptr; | |
JSValueRef res = | |
JSEvaluateScript(ctx_, sourceRef, nullptr, sourceURLRef, 0, &exc); | |
JSStringRelease(sourceRef); | |
if (sourceURLRef) { | |
JSStringRelease(sourceURLRef); | |
} | |
checkException(res, exc); | |
return createValue(res); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment