修复 把UiCollection的行为改为和以前相同
This commit is contained in:
@@ -50,6 +50,25 @@ bridges.toArray = function (iterable) {
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
bridges.asArray = function (list) {
|
||||
var arr = [];
|
||||
for (var i = 0; i < list.size(); i++) {
|
||||
arr.push(list.get(i));
|
||||
}
|
||||
for (var key in list) {
|
||||
if (typeof (key) == 'number')
|
||||
continue;
|
||||
var v = list[key];
|
||||
if (typeof (v) == 'function') {
|
||||
arr[key] = v.bind(list);
|
||||
} else {
|
||||
arr[key] = v;
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
bridges.toString = function (o) {
|
||||
return String(o);
|
||||
};
|
||||
|
||||
@@ -176,14 +176,7 @@ public class RhinoJavaScriptEngine extends JavaScriptEngine {
|
||||
if (obj instanceof String) {
|
||||
result = getRuntime().bridges.toString(obj.toString());
|
||||
} else if (staticType == UiObjectCollection.class) {
|
||||
UiObjectCollection collection = (UiObjectCollection) obj;
|
||||
Object[] array = new Object[collection.size()];
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = wrapAsJavaObject(cx, scope, collection.get(i), UiObject.class);
|
||||
}
|
||||
NativeArray nativeArray = new NativeArray(array);
|
||||
nativeArray.setPrototype(TopLevel.getBuiltinPrototype(scope, TopLevel.Builtins.Array));
|
||||
result = new NativeArrayLikeJavaObject(scope, collection, staticType, nativeArray);
|
||||
result = getRuntime().bridges.asArray(obj);
|
||||
} else {
|
||||
result = super.wrap(cx, scope, obj, staticType);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ package com.stardust.autojs.runtime;
|
||||
public class ScriptBridges {
|
||||
|
||||
|
||||
|
||||
public interface Bridges {
|
||||
|
||||
Object[] NO_ARGUMENTS = new Object[0];
|
||||
@@ -17,6 +18,7 @@ public class ScriptBridges {
|
||||
|
||||
Object toString(Object obj);
|
||||
|
||||
Object asArray(Object obj);
|
||||
}
|
||||
|
||||
private Bridges mBridges;
|
||||
@@ -46,4 +48,8 @@ public class ScriptBridges {
|
||||
return mBridges.toString(obj);
|
||||
}
|
||||
|
||||
public Object asArray(Object obj) {
|
||||
checkBridges();
|
||||
return mBridges.asArray(obj);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user