@Override protected ScriptExecutorPool<?> createScriptExecutorPool(ClasspathScriptProvider classpathScriptProvider, int poolSize, boolean sandboxing) { if(sandboxing) { throw new SandboxingUnsupportedException(SCRIPTING_LANGUAGE); } return new PythonScriptExecutorPool(this, poolSize); }
@Override public ScriptExecutionTask<?> execute(int scriptId, ScriptBindings scriptBindings, ScriptInvocationListener invocationListener) { ScriptExecutor<PyCode> executor = allocateExecutor(); if (executor == null) { throw new ScriptExecutorUnavailableException(scriptId); } return new ScriptExecutionTask<PyCode>(gameScriptingEngine, executor, scripts.get(scriptId), scriptBindings, invocationListener); }
@Override public int preCompileScript(String scriptContent) throws InsufficientCompilersException { ScriptExecutor<PyCode> executor = executors.poll(); if (executor == null) { throw new InsufficientCompilersException(); } GameScript<PyCode> script = executor.compile(scriptContent); executor.release(); scripts.put(script.getId(), script); return script.getId(); }
} catch (Exception e) { if(e.getMessage().contains(ScriptSkippedException.class.getName())) { throw new ScriptSkippedException(); } else if(e.getCause() instanceof ScriptSkippedException) { throw new ScriptSkippedException(); } else { throw e;
@Override public ScriptExecutionTask<?> execute(int scriptId, ScriptBindings scriptBindings, ScriptInvocationListener invocationListener) { ScriptExecutor<EmbedEvalUnit> executor = allocateExecutor(); if (executor == null) { throw new ScriptExecutorUnavailableException(scriptId); } return new ScriptExecutionTask<EmbedEvalUnit>(gameScriptingEngine, executor, scripts.get(scriptId), scriptBindings, invocationListener); }
@Override public ScriptExecutionResult execute(GameScript<PyCode> script, ScriptBindings bindings, boolean returnResult) throws Exception { PyCode pythonScript = script.getScript(); for (String variableName : bindings.keySet()) { pythonInterpreter.set(variableName, bindings.get(variableName)); } try { pythonInterpreter.exec(pythonScript); } catch (PyException e) { if(e.getCause() instanceof ScriptSkippedException) { throw new ScriptSkippedException(); } else { throw e; } } if(!returnResult) { return null; } //TODO: Find way to extract all variables ScriptExecutionResult executionResult = new ScriptExecutionResult(null); for(String variableName : bindings.keySet()) { executionResult.put(variableName, pythonInterpreter.get(variableName, Object.class)); } return executionResult; }
@Override protected ScriptExecutorPool<?> createScriptExecutorPool(ClasspathScriptProvider classpathScriptProvider, int poolSize, boolean sandboxing) { if(sandboxing) { throw new SandboxingUnsupportedException(SCRIPTING_LANGUAGE); } return new RubyScriptExecutorPool(this, poolSize); }
@Override public int preCompileScript(String scriptContent) throws InsufficientCompilersException { ScriptExecutor<CompiledKotlinScript> executor = executors.poll(); if (executor == null) { throw new InsufficientCompilersException(); } GameScript<CompiledKotlinScript> script = executor.compile(scriptContent); executor.release(); scripts.put(script.getId(), script); return script.getId(); }
@Override public ScriptExecutionTask<?> execute(int scriptId, ScriptBindings scriptBindings, ScriptInvocationListener invocationListener) { ScriptExecutor<LuaValue> executor = allocateExecutor(); if (executor == null) { throw new ScriptExecutorUnavailableException(scriptId); } return new ScriptExecutionTask<LuaValue>(gameScriptingEngine, executor, scripts.get(scriptId), scriptBindings, invocationListener); }
@Override public ScriptExecutionResult execute(GameScript<EmbedEvalUnit> s, ScriptBindings bindings, boolean returnResult) throws Exception { PerThreadGameScript<EmbedEvalUnit> script = (PerThreadGameScript<EmbedEvalUnit>) s; ScriptingContainer scriptingContainer = executorPool.getLocalScriptingContainer(); scriptingContainer.getVarMap().putAll(bindings); if (!script.hasScript()) { script.setScript(scriptingContainer.parse(script.getContent())); } try { EmbedEvalUnit embedEvalUnit = script.getScript(); embedEvalUnit.run(); } catch (Exception e) { if(e.getCause() instanceof ScriptSkippedException) { throw new ScriptSkippedException(); } else { throw e; } } if (!returnResult) { scriptingContainer.clear(); return null; } ScriptExecutionResult executionResult = new ScriptExecutionResult(scriptingContainer.getVarMap().getMap()); scriptingContainer.clear(); return executionResult; }
@Override protected ScriptExecutorPool<?> createScriptExecutorPool(ClasspathScriptProvider classpathScriptProvider, int poolSize, boolean sandboxing) { if(sandboxing) { throw new SandboxingUnsupportedException(SCRIPTING_LANGUAGE); } System.setProperty("idea.io.use.fallback", "true"); return new KotlinScriptExecutorPool(this, poolSize); }
@Override public ScriptExecutionTask<?> execute(int scriptId, ScriptBindings scriptBindings, ScriptInvocationListener invocationListener) { ScriptExecutor<CompiledKotlinScript> executor = allocateExecutor(); if (executor == null) { throw new ScriptExecutorUnavailableException(scriptId); } return new ScriptExecutionTask<CompiledKotlinScript>(gameScriptingEngine, executor, scripts.get(scriptId), scriptBindings, invocationListener); }
} catch (Exception e) { if(e.getCause() instanceof ScriptSkippedException) { throw new ScriptSkippedException(); } else { throw e;