Let LuaValue.checkfunction() return a LuaFunction

This commit is contained in:
James Roseborough
2013-07-06 15:18:39 +00:00
parent 729d7bb9da
commit efe0dc42bd
3 changed files with 8 additions and 10 deletions

View File

@@ -50,7 +50,7 @@ public class LuaFunction extends LuaValue {
return true;
}
public LuaValue checkfunction() {
public LuaFunction checkfunction() {
return this;
}

View File

@@ -650,8 +650,7 @@ public class LuaValue extends Varargs {
/** Check that optional argument is a function and return as {@link LuaFunction}
* <p>
* A {@link LuaFunction} may either be a Java function that implements
* functionality directly in Java,
* or a {@link LuaClosure}
* functionality directly in Java, or a {@link LuaClosure}
* which is a {@link LuaFunction} that executes lua bytecode.
* @param defval {@link LuaFunction} to return if {@code this} is nil or none
* @return {@code this} cast to {@link LuaFunction} if a function,
@@ -862,15 +861,14 @@ public class LuaValue extends Varargs {
/** Check that the value is a function , or throw {@link LuaError} if not
* <p>
* A function is considered anything whose {@link type()} returns {@link TFUNCTION}.
* In practice it will be either a built-in Java function, typically deriving from
* {@link LuaFunction} or a {@link LuaClosure} which represents lua source compiled
* into lua bytecode.
* @return {@code this} if if a lua function or closure
* A {@link LuaFunction} may either be a Java function that implements
* functionality directly in Java, or a {@link LuaClosure}
* which is a {@link LuaFunction} that executes lua bytecode.
* @return {@code this} if it is a lua function or closure
* @throws LuaError if not a function
* @see #checkclosure()
*/
public LuaValue checkfunction() { argerror("function"); return null; }
public LuaFunction checkfunction() { argerror("function"); return null; }
/** Check that the value is a Globals instance, or throw {@link LuaError} if not

View File

@@ -298,7 +298,7 @@ public abstract class Varargs {
* @return LuaValue that can be called if argument i is lua function or closure
* @exception LuaError if the argument is not a lua function or closure
* */
public LuaValue checkfunction(int i) { return arg(i).checkfunction(); }
public LuaFunction checkfunction(int i) { return arg(i).checkfunction(); }
/** Return argument i as a java int value, discarding any fractional part, or throw an error if not a number.
* @param i the index of the argument to test, 1 is the first argument