@Test (expected = IllegalStateException.class) public void testExecNotExistentScript () throws CallException { LuaScriptEngine engine = new LuaScriptEngine(); engine.execScript("test"); }
@Override public Object execScript(String scriptName, Object... args) throws CallException { Log.v(SCRIPTS_TAG, "execScript: " + scriptName); LuaFunction func = this.luaFunctions.get(scriptName); if (func == null) { throw new IllegalStateException("lua script '" + scriptName + "' doesn't exists in cache, you have to compile it first!"); } Log.d(SCRIPTS_TAG, "execute lua script '" + scriptName + "'"); try { Object[] objs = DirectCallExecutor.newExecutor().call(state, func); if (objs.length > 0) { return objs[0]; } else { return null; } } catch (CallException e) { Log.w(SCRIPTS_TAG, "CallException: ", e); throw e; } catch (CallPausedException e) { Log.w(SCRIPTS_TAG, "CallPausedException: ", e); } catch (InterruptedException e) { Log.w(SCRIPTS_TAG, "InterruptedException: ", e); } return null; }
LuaScriptEngine implements IScriptEngine { @Override public Object execScript(String scriptName, Object... args) throws CallException { Log.v(SCRIPTS_TAG, "execScript: " + scriptName); LuaFunction func = this.luaFunctions.get(scriptName); if (func == null) { throw new IllegalStateException("lua script '" + scriptName + "' doesn't exists in cache, you have to compile it first!"); } Log.d(SCRIPTS_TAG, "execute lua script '" + scriptName + "'"); try { Object[] objs = DirectCallExecutor.newExecutor().call(state, func); if (objs.length > 0) { return objs[0]; } else { return null; } } catch (CallException e) { Log.w(SCRIPTS_TAG, "CallException: ", e); throw e; } catch (CallPausedException e) { Log.w(SCRIPTS_TAG, "CallPausedException: ", e); } catch (InterruptedException e) { Log.w(SCRIPTS_TAG, "InterruptedException: ", e); } return null; } }
LuaScriptEngine implements IScriptEngine { @Override public Object execScript(String scriptName, Object... args) throws CallException { Log.v(SCRIPTS_TAG, "execScript: " + scriptName); LuaFunction func = this.luaFunctions.get(scriptName); if (func == null) { throw new IllegalStateException("lua script '" + scriptName + "' doesn't exists in cache, you have to compile it first!"); } Log.d(SCRIPTS_TAG, "execute lua script '" + scriptName + "'"); try { Object[] objs = DirectCallExecutor.newExecutor().call(state, func); if (objs.length > 0) { return objs[0]; } else { return null; } } catch (CallException e) { Log.w(SCRIPTS_TAG, "CallException: ", e); throw e; } catch (CallPausedException e) { Log.w(SCRIPTS_TAG, "CallPausedException: ", e); } catch (InterruptedException e) { Log.w(SCRIPTS_TAG, "InterruptedException: ", e); } return null; } LuaScriptEngine(); }
LuaScriptEngine implements IScriptEngine { @Override public Object execScript(String scriptName, Object... args) throws CallException { Log.v(SCRIPTS_TAG, "execScript: " + scriptName); LuaFunction func = this.luaFunctions.get(scriptName); if (func == null) { throw new IllegalStateException("lua script '" + scriptName + "' doesn't exists in cache, you have to compile it first!"); } Log.d(SCRIPTS_TAG, "execute lua script '" + scriptName + "'"); try { Object[] objs = DirectCallExecutor.newExecutor().call(state, func); if (objs.length > 0) { return objs[0]; } else { return null; } } catch (CallException e) { Log.w(SCRIPTS_TAG, "CallException: ", e); throw e; } catch (CallPausedException e) { Log.w(SCRIPTS_TAG, "CallPausedException: ", e); } catch (InterruptedException e) { Log.w(SCRIPTS_TAG, "InterruptedException: ", e); } return null; } LuaScriptEngine(); @Override void compile(String scriptName, String programStr); @Override void loadFile(File file); @Override Object execFunc(String funcName, Object... args); @Override Object execFunc(String funcName); @Override Object execScript(String scriptName, Object... args); @Override void shutdown(); }
LuaScriptEngine implements IScriptEngine { @Override public Object execScript(String scriptName, Object... args) throws CallException { Log.v(SCRIPTS_TAG, "execScript: " + scriptName); LuaFunction func = this.luaFunctions.get(scriptName); if (func == null) { throw new IllegalStateException("lua script '" + scriptName + "' doesn't exists in cache, you have to compile it first!"); } Log.d(SCRIPTS_TAG, "execute lua script '" + scriptName + "'"); try { Object[] objs = DirectCallExecutor.newExecutor().call(state, func); if (objs.length > 0) { return objs[0]; } else { return null; } } catch (CallException e) { Log.w(SCRIPTS_TAG, "CallException: ", e); throw e; } catch (CallPausedException e) { Log.w(SCRIPTS_TAG, "CallPausedException: ", e); } catch (InterruptedException e) { Log.w(SCRIPTS_TAG, "InterruptedException: ", e); } return null; } LuaScriptEngine(); @Override void compile(String scriptName, String programStr); @Override void loadFile(File file); @Override Object execFunc(String funcName, Object... args); @Override Object execFunc(String funcName); @Override Object execScript(String scriptName, Object... args); @Override void shutdown();  }