* To iterate over integer keys in a table you can use *
{@code
- * LuaValue k = LuaValue.NIL;
- * while ( true ) {
- * Varargs n = table.inext(k);
- * if ( (k = n.arg1()).isnil() )
- * break;
- * LuaValue v = n.arg(2)
- * process( k, v )
- * }
+ * LuaValue k = LuaValue.NIL;
+ * while ( true ) {
+ * Varargs n = table.inext(k);
+ * if ( (k = n.arg1()).isnil() )
+ * break;
+ * LuaValue v = n.arg(2)
+ * process( k, v )
+ * }
+ * }
* @param index {@link LuaInteger} value identifying a key to start from,
* or {@link NIL} to start at the beginning
- * @return {@link Varargs} containing {key,value} for the next entry,
+ * @return {@link Varargs} containing {@code (key,value)} for the next entry,
* or {@link NONE} if there are no more.
* @throws LuaError if {@code this} is not a table, or the supplied key is invalid.
* @see LuaTable
diff --git a/src/jse/org/luaj/vm2/lib/jse/CoerceJavaToLua.java b/src/jse/org/luaj/vm2/lib/jse/CoerceJavaToLua.java
index 75be82fa..6b5e58df 100644
--- a/src/jse/org/luaj/vm2/lib/jse/CoerceJavaToLua.java
+++ b/src/jse/org/luaj/vm2/lib/jse/CoerceJavaToLua.java
@@ -31,12 +31,38 @@ import org.luaj.vm2.LuaValue;
/**
* Helper class to coerce values from Java to lua within the luajava library.
+ * + * This class is primarily used by the {@link LuajavaLib}, + * but can also be used directly when working with Java/lua bindings. + *
+ * To coerce scalar types, the various, generally the {@code valueOf(type)} methods + * on {@link LuaValue} may be used: + *
+ * To coerce arrays of objects and lists, the {@code listOf(..)} and {@code tableOf(...)} methods + * on {@link LuaValue} may be used: + *
+ * Integral types {@code boolean}, {@code byte}, {@code char}, and {@code int} + * will become {@link LuaInteger}; + * {@code long}, {@code float}, and {@code double} will become {@link LuaDouble}; + * {@code String} and {@code byte[]} will become {@link LuaString}; + * other types will become {@link LuaUserdata}. + * @param o Java object needing conversion + * @return {@link LuaValue} corresponding to the supplied Java value. + * @see LuaValue + * @see LuaInteger + * @see LuaDouble + * @see LuaString + * @see LuaUserdata + */ public static LuaValue coerce(Object o) { if ( o == null ) return LuaValue.NIL; diff --git a/src/jse/org/luaj/vm2/lib/jse/CoerceLuaToJava.java b/src/jse/org/luaj/vm2/lib/jse/CoerceLuaToJava.java index cea1ab29..e759c534 100644 --- a/src/jse/org/luaj/vm2/lib/jse/CoerceLuaToJava.java +++ b/src/jse/org/luaj/vm2/lib/jse/CoerceLuaToJava.java @@ -31,12 +31,34 @@ import org.luaj.vm2.Varargs; /** * Helper class to coerce values from lua to Java within the luajava library. + *
+ * This class is primarily used by the {@link LuajavaLib}, + * but can also be used directly when working with Java/lua bindings. + *
+ * To coerce to specific Java values, generally the {@code toType()} methods + * on {@link LuaValue} may be used: + *
+ * For data in lua tables, the various methods on {@link LuaTable} can be used directly + * to convert data to something more useful. * * @see LuajavaLib + * @see CoerceJavaToLua */ public class CoerceLuaToJava { - public static interface Coercion { + static interface Coercion { public Object coerce( LuaValue value ); public int score( int paramType ); };