Android Open Source - non lua






From Project

Back to project page non.

License

The source code is released under:

MIT License

If you think the Android project non listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package non.languages;
/*  www  .  j  a  v  a 2  s.com*/
import java.util.HashMap;
import org.luaj.vm2.*;
import org.luaj.vm2.lib.jse.*;

public class lua extends Language {
    public String extension() { return "lua"; }
    public String version()   { return "5.1"; }
    
    private final Globals _G;
    
    public lua() {
        _G = JsePlatform.standardGlobals();
    }

    public Object invoke(String object, String method, Object... args) {
        LuaValue func;
        if (method != null) {
            func = _G.get(object).get(method);
        } else {
            func = _G.get(object);
        }

        if (func == LuaValue.NIL) return LuaValue.NIL;
        
        if (args != null) {
            LuaValue[] values = new LuaValue[args.length];
            for (int i = 0; i < args.length; i++) values[i] = (LuaValue)convert(args[i]);
      
            switch(values.length) {
                case 1: return func.call(values[0]);
                case 2: return func.call(values[0], values[1]);
                case 3: return func.call(values[0], values[1], values[2]);
            }
      
            return func.call(LuaValue.listOf(values));
        } else {
            return func.call();
        }
    }

    public Object eval(String script) {
        return _G.load(script).call();
    }

    public void put(String key, Object value) {
        _G.set((LuaValue)convert(key), (LuaValue)convert(value));
    }
    
    public Object get(String key) {
        return _G.get(key);
    }
    
    public Object convert(Object javaValue) {
        return javaValue == null? LuaValue.NIL:
               javaValue instanceof LuaValue? javaValue:
               CoerceJavaToLua.coerce(javaValue);
    }
}




Java Source Code List

%PACKAGE%.android.AndroidLauncher.java
%PACKAGE%.desktop.DesktopLauncher.java
%PACKAGE%.ios.IOSLauncher.java
launcher.Main.java
non.InputHandle.java
non.Line.java
non.NonBuffer.java
non.Non.java
non.Quad.java
non.languages.Language.java
non.languages.javascript.java
non.languages.lua.java
non.plugins.Plugin.java
non.plugins.audio.java
non.plugins.graphics.java
non.plugins.input.java
non.plugins.lights.java
non.plugins.math.java
non.plugins.network.java
non.plugins.non.java
non.plugins.physics.java