gorlowski / gosu-jsr223 Goto Github PK
View Code? Open in Web Editor NEWJSR 223 Script Engine for Gosu
License: Other
JSR 223 Script Engine for Gosu
License: Other
#------------------------------------------------------------- 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(); } } }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.