Other files ignored by Codecov
CHANGELOG.md
has changed.
template/res/script/main.lvn
has changed.
gradle/wrapper/gradle-wrapper.properties
has changed.
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 | + | } |
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% |