+
+ private static void recurse(String indent, String name, Object o, Context cx) {
+ if (!name.equals("")) name += " : ";
+
+ if (o == null) {
+ Log.log(cx.interpreterSourceFile, indent + name + "<null>");
+
+ } else if (o instanceof NativeArray) {
+ Log.log(cx.interpreterSourceFile, indent + name + "<array>");
+ NativeArray na = (NativeArray)o;
+ for(int i=0; i<na.jsGet_length(); i++)
+ recurse(indent + " ", i + "", na.get(i, null), cx);
+
+ } else if (o instanceof JSObject || o instanceof ScriptableObject) {
+ Log.log(cx.interpreterSourceFile, indent + name + "<object>");
+ Scriptable s = (Scriptable)o;
+ Object[] keys = s.getIds();
+ for(int i=0; i<keys.length; i++)
+ recurse(indent + " ", keys[i].toString(),
+ keys[i] instanceof Integer ? s.get(((Integer)keys[i]).intValue(), null) : s.get(keys[i].toString(), null), cx);
+
+ } else {
+ Log.log(cx.interpreterSourceFile, indent + name + o);
+
+ }
+ }
+
+ private static final JSFunction recursivePrintObject = new JSFunction() {
+ public Object call(Context cx, Scriptable thisObj, Scriptable ctorObj, Object[] args) throws JavaScriptException {
+ if (args == null || args.length != 1) return null;
+ recurse("", "", args[0], cx);
+ return null;
+ }
+ };
+