Search in sources :

Example 36 with LuaValue

use of org.luaj.vm2.LuaValue in project LuaViewSDK by alibaba.

the class DebugLib method onCall.

public void onCall(LuaClosure c, Varargs varargs, LuaValue[] stack) {
    LuaThread t = globals.running;
    callstack().onCall(c, varargs, stack);
    if (t.inhook)
        return;
    if (t.hookcall && t.hookfunc != null)
        callHook(CALL, NIL);
}
Also used : LuaThread(org.luaj.vm2.LuaThread)

Example 37 with LuaValue

use of org.luaj.vm2.LuaValue in project LuaViewSDK by alibaba.

the class PackageLib method call.

public LuaValue call(LuaValue modname, LuaValue env) {
    globals = env.checkglobals();
    globals.set("require", new require());
    package_ = new LuaTable();
    package_.set(_LOADED, new LuaTable());
    package_.set(_PRELOAD, new LuaTable());
    package_.set(_PATH, LuaValue.valueOf(DEFAULT_LUA_PATH));
    package_.set(_LOADLIB, new loadlib());
    package_.set(_SEARCHPATH, new searchpath());
    LuaTable searchers = new LuaTable();
    searchers.set(1, preload_searcher = new preload_searcher());
    searchers.set(2, lua_searcher = new lua_searcher());
    searchers.set(3, java_searcher = new java_searcher());
    package_.set(_SEARCHERS, searchers);
    package_.get(_LOADED).set("package", package_);
    env.set("package", package_);
    globals.package_ = this;
    return env;
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Example 38 with LuaValue

use of org.luaj.vm2.LuaValue in project LuaViewSDK by alibaba.

the class IoLib method freadnumber.

public static LuaValue freadnumber(File f) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    freadchars(f, " \t\r\n", null);
    freadchars(f, "-+", baos);
    // freadchars(f,"0",baos);
    // freadchars(f,"xX",baos);
    freadchars(f, "0123456789", baos);
    freadchars(f, ".", baos);
    freadchars(f, "0123456789", baos);
    // freadchars(f,"eEfFgG",baos);
    // freadchars(f,"+-",baos);
    // freadchars(f,"0123456789",baos);
    String s = baos.toString();
    return s.length() > 0 ? valueOf(Double.parseDouble(s)) : NIL;
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) LuaString(org.luaj.vm2.LuaString)

Example 39 with LuaValue

use of org.luaj.vm2.LuaValue in project LuaViewSDK by alibaba.

the class MathLib method call.

public LuaValue call(LuaValue modname, LuaValue env) {
    LuaTable math = new LuaTable(0, 30);
    math.set("abs", new abs());
    math.set("ceil", new ceil());
    math.set("cos", new cos());
    math.set("deg", new deg());
    math.set("exp", new exp(this));
    math.set("floor", new floor());
    math.set("fmod", new fmod());
    math.set("frexp", new frexp());
    math.set("huge", LuaDouble.POSINF);
    math.set("ldexp", new ldexp());
    math.set("max", new max());
    math.set("min", new min());
    math.set("modf", new modf());
    math.set("pi", Math.PI);
    math.set("pow", new pow());
    random r;
    math.set("random", r = new random());
    math.set("randomseed", new randomseed(r));
    math.set("rad", new rad());
    math.set("sin", new sin());
    math.set("sqrt", new sqrt());
    math.set("tan", new tan());
    env.set("math", math);
    env.get("package").get("loaded").set("math", math);
    return math;
}
Also used : LuaTable(org.luaj.vm2.LuaTable)

Example 40 with LuaValue

use of org.luaj.vm2.LuaValue in project LuaViewSDK by alibaba.

the class FuncState method addk.

int addk(LuaValue v) {
    if (this.h == null) {
        this.h = new Hashtable();
    } else if (this.h.containsKey(v)) {
        return ((Integer) h.get(v)).intValue();
    }
    final int idx = this.nk;
    this.h.put(v, new Integer(idx));
    final Prototype f = this.f;
    if (f.k == null || nk + 1 >= f.k.length)
        f.k = realloc(f.k, nk * 2 + 1);
    f.k[this.nk++] = v;
    return idx;
}
Also used : LuaInteger(org.luaj.vm2.LuaInteger) Prototype(org.luaj.vm2.Prototype) Hashtable(java.util.Hashtable)

Aggregations

LuaValue (org.luaj.vm2.LuaValue)55 LuaTable (org.luaj.vm2.LuaTable)37 Varargs (org.luaj.vm2.Varargs)12 LuaString (org.luaj.vm2.LuaString)9 VarArgFunction (org.luaj.vm2.lib.VarArgFunction)7 UDView (com.taobao.luaview.userdata.ui.UDView)6 LuaError (org.luaj.vm2.LuaError)6 LuaFunction (org.luaj.vm2.LuaFunction)6 View (android.view.View)4 Point (android.graphics.Point)3 ILVView (com.taobao.luaview.view.interfaces.ILVView)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 JSONObject (org.json.JSONObject)3 HorizontalScrollView (android.widget.HorizontalScrollView)2 AerospikeException (com.aerospike.client.AerospikeException)2 LuaViewApi (com.taobao.luaview.fun.mapper.LuaViewApi)2 UDLuaTable (com.taobao.luaview.userdata.base.UDLuaTable)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2