--****************************************************************************** --* * --* File: LuaJava_02.lua Revision: 1.0 * --* * --* Purpose: how are LuaObjects converted into strings within Java? * --* * --* Creation: 06.11.2004 Last Modification: 07.11.2004 * --* * --* Platform: IBM-compatible PC running Windows 98SE * --* * --* Environment: Lua 5.0, LuaJava 1.0b3, Java 1.4.2 * --* * --* Author: Andreas Rozek Phone: ++49 (7031) 222305 * --* Bunsenstraße 80/1 Fax: - * --* D-71032 Böblingen EMail: Info@Andreas-Rozek.De * --* Germany * --* * --* URL: http://www.Andreas-Rozek.de/ * --* * --* Copyright: the software is published under the "GNU Lesser General Pub- * --* lic License" (see "http://www.fsf.org/copyleft/lesser.html" * --* for additional information) * --* * --* Comments: (none) * --* * --****************************************************************************** println(); println("LuaJava_02 - how are LuaObjects converted into strings within Java?"); println(); local SystemClass = luajava.bindClass("java.lang.System"); local function Function () end; local Thread = coroutine.create(Function); println("Output of 'println(arg,' <-> ',tostring(arg))' depending on 'arg':"); println(" nil -> ", nil, " <-> ", tostring(nil)); println(" true -> ", true, " <-> ", tostring(true)); println(" false -> ", false, " <-> ", tostring(false)); println(" 1 -> ", 1, " <-> ", tostring(1)); println(" 1.23 -> ", 1.23, " <-> ", tostring(1.23)); println(" 1.23e45 -> ", 1.23e45, " <-> ", tostring(1.23e45)); println(" 'Test' -> ", 'Test', " <-> ", tostring('Test')); println(" {1,2,3} -> ", {1,2,3}, " <-> ", tostring({1,2,3})); println(" Function -> ", Function, " <-> ", tostring(Function)); --println(" Thread -> ", Thread , " <-> ", tostring(Thread)); -- throws java.lang.NullPointerException println(" -> ", SystemClass, " <-> ", tostring(SystemClass)); println(); println("Output of 'io.stdout:write(tostring(arg))' depending on 'arg':"); io.stdout:write(" nil -> ", tostring(nil), "\n"); io.stdout:write(" true -> ", tostring(true), "\n"); io.stdout:write(" false -> ", tostring(false), "\n"); io.stdout:write(" 1 -> ", tostring(1), "\n"); io.stdout:write(" 1.23 -> ", tostring(1.23), "\n"); io.stdout:write(" 1.23e45 -> ", tostring(1.23e45), "\n"); io.stdout:write(" 'Test' -> ", tostring('Test'), "\n"); io.stdout:write(" {1,2,3} -> ", tostring({1,2,3}), "\n"); io.stdout:write(" Function -> ", tostring(Function), "\n"); io.stdout:write(" Thread -> ", tostring(Thread), "\n"); io.stdout:write(" -> ", tostring(SystemClass), "\n");