Use ascii characters to construct JSStringRef

Reviewed By: astreet

Differential Revision: D2700781

fb-gh-sync-id: be790600ea3d4c0238553efe69a0979c177ddb2d
This commit is contained in:
Mike Armstrong 2015-12-08 01:35:57 -08:00 committed by facebook-github-bot-1
parent a659c9346c
commit dcebe8cd37
2 changed files with 12 additions and 2 deletions

View File

@ -117,9 +117,8 @@ void JSCExecutor::executeApplicationScript(
jstring endStringMarker = env->NewStringUTF("executeApplicationScript_endStringConvert");
env->CallStaticVoidMethod(markerClass, logMarkerMethod, startStringMarker);
String jsScript(script.c_str());
String jsScript = String::createExpectingAscii(script);
env->CallStaticVoidMethod(markerClass, logMarkerMethod, endStringMarker);
env->DeleteLocalRef(startStringMarker);
env->DeleteLocalRef(endStringMarker);

View File

@ -8,6 +8,9 @@
#include <JavaScriptCore/JSStringRef.h>
#include <JavaScriptCore/JSValueRef.h>
#include <fb/noncopyable.h>
#if WITH_FBJSCEXTENSIONS
#include <jsc_stringref.h>
#endif
namespace facebook {
namespace react {
@ -53,6 +56,14 @@ public:
return JSStringIsEqualToUTF8CString(m_string.get(), utf8);
}
static String createExpectingAscii(std::string const &utf8) {
#if WITH_FBJSCEXTENSIONS
return String(Adopt, JSStringCreateWithUTF8CStringExpectAscii(utf8.c_str(), utf8.size()));
#else
return String(Adopt, JSStringCreateWithUTF8CString(utf8.c_str()));
#endif
}
static String ref(JSStringRef string) {
return String(string);
}