Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add in Compilable interface (and use in all cases). * Add in Invocable interface for creating Java interfaces from JS implementations.
- Loading branch information
1 parent
f8cc6c1
commit 36f4db4
Showing
9 changed files
with
248 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.dynjs.jsr223; | ||
|
||
import org.dynjs.Config; | ||
import org.dynjs.runtime.DynJS; | ||
import org.dynjs.runtime.JSProgram; | ||
import org.dynjs.runtime.Types; | ||
import org.dynjs.runtime.builtins.DynJSBuiltin; | ||
|
||
import javax.script.CompiledScript; | ||
import javax.script.ScriptContext; | ||
import javax.script.ScriptEngine; | ||
import javax.script.ScriptException; | ||
|
||
/** | ||
* @author Bob McWhirter | ||
*/ | ||
public class DynJSCompiledScript extends CompiledScript { | ||
|
||
private final DynJSScriptEngine engine; | ||
private final JSProgram program; | ||
|
||
DynJSCompiledScript(DynJSScriptEngine engine, JSProgram program) { | ||
this.engine = engine; | ||
this.program = program; | ||
} | ||
|
||
@Override | ||
public Object eval(ScriptContext context) throws ScriptException { | ||
ScriptEngineGlobalObject global = RuntimeHelper.getGlobalObject( context ); | ||
DynJS runtime = RuntimeHelper.getRuntime( global, context ); | ||
return runtime.newRunner().withSource( this.program ).execute(); | ||
} | ||
|
||
@Override | ||
public ScriptEngine getEngine() { | ||
return this.engine; | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.