package androlua;


import com.luajava.JavaFunction;
import com.luajava.LuaException;
import com.luajava.LuaState;

import common.LuaLog;

public class LuaPrint extends JavaFunction {

    private LuaState L;
    private StringBuilder output = new StringBuilder();

    public LuaPrint(LuaState L) {
        super(L);
        this.L = L;
    }

    @Override
    public int execute() throws LuaException {
        if (L.getTop() < 2) {
            LuaLog.e("error print");
            return 0;
        }
        for (int i = 2; i <= L.getTop(); i++) {
            int type = L.type(i);
            String val = null;
            String stype = L.typeName(type);
            if (stype.equals("userdata")) {
                Object obj = L.toJavaObject(i);
                if (obj != null)
                    val = obj.toString();
            } else if (stype.equals("boolean")) {
                val = L.toBoolean(i) ? "true" : "false";
            } else {
                val = L.toString(i);
            }
            if (val == null)
                val = stype;
            output.append("\t");
            output.append(val);
            output.append("\t");
        }
        LuaLog.e(output.toString().substring(1, output.length() - 1));
        output.setLength(0);
        return 0;
    }


}


@@ -13,16 +13,42 @@
 olua;%0A%0A%0A
+import android.util.Log;%0A%0A
 import c
@@ -1202,25 +1202,34 @@
         
-Lua
 Log.e(
+%22Luandroid%22,
 output.t

update LuaPaint