コード例 #1
0
ファイル: JSCExecutor.cpp プロジェクト: 4DKelvin/react-native
void JSCExecutor::loadApplicationScript(
    const std::string& script,
    const std::string& sourceURL) {
  ReactMarker::logMarker("loadApplicationScript_startStringConvert");
#if WITH_FBJSCEXTENSIONS
  JSStringRef jsScriptRef;
  if (usePreparsingAndStringRef()){
    jsScriptRef = JSStringCreateWithUTF8CStringExpectAscii(script.c_str(), script.size());
  } else {
    jsScriptRef = JSStringCreateWithUTF8CString(script.c_str());
  }

  String jsScript = String::adopt(jsScriptRef);
#else
  String jsScript = String::createExpectingAscii(script);
#endif
  
  ReactMarker::logMarker("loadApplicationScript_endStringConvert");

  String jsSourceURL(sourceURL.c_str());
  #ifdef WITH_FBSYSTRACE
  FbSystraceSection s(TRACE_TAG_REACT_CXX_BRIDGE, "JSCExecutor::loadApplicationScript",
    "sourceURL", sourceURL);
  #endif
  if (!jsSourceURL || !usePreparsingAndStringRef()) {
    evaluateScript(m_context, jsScript, jsSourceURL);
  } else {
    // If we're evaluating a script, get the device's cache dir
    //  in which a cache file for that script will be stored.
    evaluateScript(m_context, jsScript, jsSourceURL, m_deviceCacheDir.c_str());
  }
  flush();
  ReactMarker::logMarker("CREATE_REACT_CONTEXT_END");
}
コード例 #2
0
ファイル: JSCExecutor.cpp プロジェクト: DYS1230/react-native
void JSCExecutor::loadApplicationScript(
    const std::string& script,
    const std::string& sourceURL) {
  ReactMarker::logMarker("loadApplicationScript_startStringConvert");
  String jsScript = String::createExpectingAscii(script);
  ReactMarker::logMarker("loadApplicationScript_endStringConvert");

  String jsSourceURL(sourceURL.c_str());
  #ifdef WITH_FBSYSTRACE
  FbSystraceSection s(TRACE_TAG_REACT_CXX_BRIDGE, "JSCExecutor::loadApplicationScript",
    "sourceURL", sourceURL);
  #endif
  evaluateScript(m_context, jsScript, jsSourceURL);
  flush();
  ReactMarker::logMarker("CREATE_REACT_CONTEXT_END");
}
コード例 #3
0
void JSCExecutor::executeApplicationScript(
    const std::string& script,
    const std::string& sourceURL) {
    ReactMarker::logMarker("executeApplicationScript_startStringConvert");
    String jsScript = String::createExpectingAscii(script);
    ReactMarker::logMarker("executeApplicationScript_endStringConvert");

    String jsSourceURL(sourceURL.c_str());
#ifdef WITH_FBSYSTRACE
    FbSystraceSection s(TRACE_TAG_REACT_CXX_BRIDGE, "JSCExecutor::executeApplicationScript",
                        "sourceURL", sourceURL);
#endif
    if (!jsSourceURL) {
        evaluateScript(m_context, jsScript, jsSourceURL);
    } else {
        // If we're evaluating a script, get the device's cache dir
        //  in which a cache file for that script will be stored.
        evaluateScript(m_context, jsScript, jsSourceURL, m_deviceCacheDir.c_str());
    }
}
コード例 #4
0
void JSCExecutor::executeApplicationScript(
    const std::string& script,
    const std::string& sourceURL) {
  JNIEnv* env = Environment::current();
  jclass markerClass = env->FindClass("com/facebook/react/bridge/ReactMarker");
  jmethodID logMarkerMethod = facebook::react::getLogMarkerMethod();
  jstring startStringMarker = env->NewStringUTF("executeApplicationScript_startStringConvert");
  jstring endStringMarker = env->NewStringUTF("executeApplicationScript_endStringConvert");

  env->CallStaticVoidMethod(markerClass, logMarkerMethod, startStringMarker);
  String jsScript = String::createExpectingAscii(script);
  env->CallStaticVoidMethod(markerClass, logMarkerMethod, endStringMarker);
  env->DeleteLocalRef(startStringMarker);
  env->DeleteLocalRef(endStringMarker);

  String jsSourceURL(sourceURL.c_str());
  #ifdef WITH_FBSYSTRACE
  FbSystraceSection s(TRACE_TAG_REACT_CXX_BRIDGE, "JSCExecutor::executeApplicationScript",
    "sourceURL", sourceURL);
  #endif
  evaluateScriptWithJSC(m_context, jsScript, jsSourceURL);
}