コード例 #1
0
ファイル: Platform.java プロジェクト: hnney/android-runtime
  public static int init(
      Object application,
      String appName,
      File runtimeLibPath,
      File rootDir,
      File appDir,
      File debuggerSetupDir,
      ClassLoader classLoader,
      File dexDir,
      String dexThumb)
      throws RuntimeException {
    if (initialized) {
      throw new RuntimeException("NativeScriptApplication already initialized");
    }

    loadLibrary(runtimeLibPath, "NativeScript");

    mainThread = Thread.currentThread();

    Platform.dexFactory = new DexFactory(classLoader, dexDir, dexThumb);

    int appJavaObjectId = -1;
    if (application != null) {
      if (IsLogEnabled) Log.d(DEFAULT_LOG_TAG, "Initializing NativeScript JAVA");
      appJavaObjectId = generateNewObjectId();
      makeInstanceStrong(application, appJavaObjectId);
      if (IsLogEnabled) Log.d(DEFAULT_LOG_TAG, "Initialized app instance id:" + appJavaObjectId);
    }

    try {
      Require.init(rootDir, appDir);
    } catch (IOException ex) {
      throw new RuntimeException("Fail to initialize Require class", ex);
    }
    String jsOptions = readJsOptions(appDir);
    Platform.initNativeScript(
        Require.getApplicationFilesPath(), appJavaObjectId, IsLogEnabled, appName, jsOptions);

    if (debuggerSetupDir != null) {
      jsDebugger = new JsDebugger(debuggerSetupDir);
      // also runs javaServerThread with resolved port
      int debuggerPort = jsDebugger.getDebuggerPortFromEnvironment();
    }

    //
    if (IsLogEnabled) {
      Date d = new Date();
      int pid = android.os.Process.myPid();
      File f = new File("/proc/" + pid);
      Date lastModDate = new Date(f.lastModified());
      Log.d(DEFAULT_LOG_TAG, "init time=" + (d.getTime() - lastModDate.getTime()));
    }
    //

    initialized = true;
    return appJavaObjectId;
  }
コード例 #2
0
ファイル: RequireParser.java プロジェクト: tinours/PCSim2
  /**
   * parse the String message
   *
   * @return SIPHeader (RequireList object)
   * @throws SIPParseException if the message does not respect the spec.
   */
  public SIPHeader parse() throws ParseException {
    RequireList requireList = new RequireList();
    if (debug) dbg_enter("RequireParser.parse");

    try {
      headerName(TokenTypes.REQUIRE);

      while (lexer.lookAhead(0) != '\n') {
        Require r = new Require();
        r.setHeaderName(SIPHeaderNames.REQUIRE);

        // Parsing the option tag
        this.lexer.match(TokenTypes.ID);
        Token token = lexer.getNextToken();
        r.setOptionTag(token.getTokenValue());
        this.lexer.SPorHT();

        requireList.add(r);

        while (lexer.lookAhead(0) == ',') {
          this.lexer.match(',');
          this.lexer.SPorHT();

          r = new Require();

          // Parsing the option tag
          this.lexer.match(TokenTypes.ID);
          token = lexer.getNextToken();
          r.setOptionTag(token.getTokenValue());
          this.lexer.SPorHT();

          requireList.add(r);
        }
      }
    } finally {
      if (debug) dbg_leave("RequireParser.parse");
    }

    return requireList;
  }
コード例 #3
0
ファイル: Platform.java プロジェクト: hnney/android-runtime
 public static void run() {
   String bootstrapPath = Require.bootstrapApp();
   runNativeScript(bootstrapPath);
 }