mirror of
https://github.com/TonyJiangWJ/Auto.js.git
synced 2026-06-21 21:01:43 +08:00
optimize: code generation
This commit is contained in:
parent
8db26f5b11
commit
be023ceefe
@ -8,8 +8,8 @@ android {
|
||||
applicationId "com.stardust.scriptdroid"
|
||||
minSdkVersion 17
|
||||
targetSdkVersion 23
|
||||
versionCode 231
|
||||
versionName "3.0.0 Alpha31"
|
||||
versionCode 233
|
||||
versionName "3.0.0 Alpha33"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
ndk {
|
||||
|
||||
@ -73,10 +73,15 @@ public class CodeGenerator {
|
||||
}
|
||||
|
||||
protected String generateCode(UiSelectorGenerator generator, UiObject root, UiObject target, int maxParentLevel, int maxChildrenLevel) {
|
||||
String selector = generator.generateSelectorCode();
|
||||
return generateCode(generator, root, target, maxParentLevel, maxChildrenLevel, true);
|
||||
}
|
||||
|
||||
protected String generateCode(UiSelectorGenerator generator, UiObject root, UiObject target, int maxParentLevel, int maxChildrenLevel, boolean withFind) {
|
||||
String selector = withFind ? generator.generateSelectorCode() : generator.generateSelector().toString();
|
||||
if (selector != null) {
|
||||
return selector;
|
||||
}
|
||||
|
||||
if (maxChildrenLevel > 0) {
|
||||
for (int i = 0; i < target.childCount(); i++) {
|
||||
UiObject child = target.child(i);
|
||||
@ -101,9 +106,13 @@ public class CodeGenerator {
|
||||
}
|
||||
|
||||
protected String generateCode(UiObject root, UiObject target, int maxParentLevel, int maxChildrenLevel) {
|
||||
return generateCode(root, target, maxParentLevel, maxChildrenLevel, true);
|
||||
}
|
||||
|
||||
protected String generateCode(UiObject root, UiObject target, int maxParentLevel, int maxChildrenLevel, boolean withFind) {
|
||||
UiSelectorGenerator generator = new UiSelectorGenerator(root, target);
|
||||
generator.setUsingId(mUsingId);
|
||||
return generateCode(generator, root, target, maxParentLevel, maxChildrenLevel);
|
||||
return generateCode(generator, root, target, maxParentLevel, maxChildrenLevel, withFind);
|
||||
}
|
||||
|
||||
private String generateAction(String selector) {
|
||||
@ -158,10 +167,10 @@ public class CodeGenerator {
|
||||
String collectionCode = generateCode(mRoot, collection, 2, 0);
|
||||
if (collectionCode == null)
|
||||
return null;
|
||||
String itemCode = generateCode(collectionItem, target, 1, 2);
|
||||
String itemCode = generateCode(collectionItem, target, 1, 2, false);
|
||||
if (itemCode == null)
|
||||
return null;
|
||||
return collectionCode + ".findOne().children().forEach(child => {\n"
|
||||
return collectionCode + ".children().forEach(child => {\n"
|
||||
+ "var target = child.findOne(" + itemCode + ");\n"
|
||||
+ "target." + getAction() + ";\n"
|
||||
+ "});";
|
||||
|
||||
@ -32,6 +32,7 @@ public class TemplateMatching {
|
||||
return fastTemplateMatching(img, template, MATCHING_METHOD_DEFAULT, 0.75f, threshold, MAX_LEVEL_AUTO);
|
||||
}
|
||||
|
||||
|
||||
public static Point fastTemplateMatching(Mat img, Mat template, int matchMethod, float weakThreshold, float strictThreshold, int maxLevel) {
|
||||
TimingLogger logger = new TimingLogger(LOG_TAG, "fast_tm");
|
||||
if (maxLevel == MAX_LEVEL_AUTO) {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.stardust.autojs.engine;
|
||||
|
||||
import android.util.Log;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.stardust.autojs.BuildConfig;
|
||||
import com.stardust.autojs.rhino.AndroidContextFactory;
|
||||
@ -165,7 +166,7 @@ public class RhinoJavaScriptEngine extends JavaScriptEngine {
|
||||
private class WrapFactory extends org.mozilla.javascript.WrapFactory {
|
||||
@Override
|
||||
public Object wrap(Context cx, Scriptable scope, Object obj, Class<?> staticType) {
|
||||
if (obj instanceof CharSequence) {
|
||||
if (obj instanceof String) {
|
||||
return getRuntime().bridges.toString(obj.toString());
|
||||
}
|
||||
if (staticType == UiObjectCollection.class) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user