anonl / nvlist

@@ -0,0 +1,52 @@
Loading
1 +
package nl.weeaboo.vn.impl.script.lua;
2 +
3 +
import javax.annotation.CheckForNull;
4 +
import javax.annotation.Nullable;
5 +
6 +
import nl.weeaboo.lua2.LuaRunState;
7 +
import nl.weeaboo.lua2.luajava.ITypeCoercions;
8 +
import nl.weeaboo.lua2.vm.LuaValue;
9 +
import nl.weeaboo.vn.script.IScriptFunction;
10 +
11 +
final class LuaTypeCoercions implements ITypeCoercions {
12 +
13 +
    private static final long serialVersionUID = 1L;
14 +
15 +
    private final ITypeCoercions delegate;
16 +
17 +
    LuaTypeCoercions(ITypeCoercions delegate) {
18 +
        this.delegate = delegate;
19 +
    }
20 +
21 +
    static LuaTypeCoercions install(LuaRunState runState) {
22 +
        LuaTypeCoercions result = new LuaTypeCoercions(runState.getTypeCoercions());
23 +
        runState.setTypeCoercions(result);
24 +
        return result;
25 +
    }
26 +
27 +
    @Override
28 +
    public <T> LuaValue toLua(@Nullable T javaValue) {
29 +
        return toLua(javaValue, javaValue != null ? javaValue.getClass() : Object.class);
30 +
    }
31 +
32 +
    @Override
33 +
    public <T> LuaValue toLua(@Nullable T javaValue, Class<?> declaredType) {
34 +
        return delegate.toLua(javaValue, declaredType);
35 +
    }
36 +
37 +
    @CheckForNull
38 +
    @Override
39 +
    public <T> T toJava(LuaValue luaValue, Class<T> javaType) {
40 +
        // Special coercion so we can call IButton.setClickHandler() from Lua
41 +
        if (IScriptFunction.class.isAssignableFrom(javaType)) {
42 +
            return javaType.cast(LuaScriptUtil.toScriptFunction(luaValue, 1));
43 +
        }
44 +
        return delegate.toJava(luaValue, javaType);
45 +
    }
46 +
47 +
    @Override
48 +
    public int scoreParam(LuaValue arg, Class<?> javaParamType) {
49 +
        return delegate.scoreParam(arg, javaParamType);
50 +
    }
51 +
52 +
}

@@ -51,6 +51,7 @@
Loading
51 51
52 52
        registerOnThread();
53 53
        loader.initEnv();
54 +
        LuaTypeCoercions.install(runState);
54 55
55 56
        for (ILuaScriptEnvInitializer init : initializers) {
56 57
            init.initEnv(this);

@@ -136,7 +136,11 @@
Loading
136 136
     *        <li>Button
137 137
     *        <li>Lua function
138 138
     *        </ol>
139 +
     *
140 +
     * @deprecated Call {@link IButton#setClickHandler(IScriptFunction)} directly from Lua like this:
141 +
     *             {@code myButton:setClickHandler(function() print("click") end)}
139 142
     */
143 +
    @Deprecated
140 144
    @ScriptFunction
141 145
    public Varargs setClickHandler(Varargs args) {
142 146
        IButton button = args.checkuserdata(1, IButton.class);
Files Complexity Coverage
api/src/main/java/nl/weeaboo/vn 91.53% 96.76%
buildtools/src/main/java/nl/weeaboo/vn/buildtools 83.33% 89.43%
core/src/main/java/nl/weeaboo/vn 82.30% 86.57%
desktop/src/main/java/nl/weeaboo/vn/desktop 1.52% 2.26%
Project Totals (382 files) 80.94% 84.30%
1
codecov:
2
  status:
3
    project: yes
4
    patch: no
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading