-
Notifications
You must be signed in to change notification settings - Fork 1
JSR 223 Script Engine for Gosu
License
gorlowski/gosu-jsr223
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
#------------------------------------------------------------- OVERVIEW #------------------------------------------------------------- This is a partially-functional JSR 223 implementation for the Gosu language. I threw this code together after I first discovered the Gosu language: http://gosu-lang.org/ Gosu itself is a finely designed, practical blend of Java and C# with some Ruby/Groovy closures + parse-time dynamicism (final types can be enhanced at parse time). Unfortunately, as of 2011-05, while much of Gosu is open source (Apache Licensed), the open source parts depend on closed-source internals, which complicate the process of creating a full JSR 223 implementation. I wasn't aware of how much was closed source until I had already thrown together this partially-working implementation. I'm publishing it mainly to give someone else a jump start if they want to create a complete JSR 223 implementation. See the java code for additional notes. #------------------------------------------------------------- BUILDING #------------------------------------------------------------- NOTE: You cannot compile this with maven without defining dependencies for gw-gosu-core-api.jar. You can alternatively create an eclipse project with: mvn eclipse:eclipse compile in eclipse, and then package with mvn package #------------------------------------------------------------- Once you build a jar, put it on your classpath along with: GOS_LIB="/path/to/gosu/jars" CP=. ### This is the jar CP=gosu-jsr-223.jar ### Core gosu jars: CP=$CP:$GOS_LIB/gw-asm-3.1.jar CP=$CP:$GOS_LIB/gw-gosu-core-api.jar CP=$CP:$GOS_LIB/gw-gosu-core.jar CP=$CP:$GOS_LIB/gw-commons-cli-1.0.jar ### These might be needed for some scripts ??? # CP=$CP:$GOS_LIB/gw-asm-analysis-3.1.jar # CP=$CP:$GOS_LIB/gw-asm-commons-3.1.jar # CP=$CP:$GOS_LIB/gw-asm-tree-3.1.jar # CP=$CP:$GOS_LIB/gw-asm-util-3.1.jar ### Execute with: java -cp "$CP" YourGosuBootStrapper #------------------------------------------------------------- /* * Sample java JSR 223 code: */ import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class YourGosuBootStrapper { public static void main(String[] args) { ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine engine = mgr.getEngineByName("gosu"); try { // This will correctly print HELLO WORLD // On my machine, the initial evaluation takes about 2 seconds, // and subsequent calls to eval (once the Gosu internals are // initialized), run in between 14 to 25 milliseconds Object ret = engine.eval("print(\"HELLO WORLD\")"); } catch (ScriptException e) { e.printStackTrace(); } } }
About
JSR 223 Script Engine for Gosu
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published