6.6.2 - Alpha5 - 同步并兼容 Rhino 引擎上游代码 (1.8.1-SNAPSHOT)
This commit is contained in:
@@ -2,6 +2,7 @@ package org.autojs.autojs.runtime.api.augment.automator
|
|||||||
|
|
||||||
import org.autojs.autojs.extension.ScriptableExtensions.prop
|
import org.autojs.autojs.extension.ScriptableExtensions.prop
|
||||||
import org.autojs.autojs.runtime.ScriptRuntime
|
import org.autojs.autojs.runtime.ScriptRuntime
|
||||||
|
import org.autojs.autojs.util.RhinoUtils
|
||||||
import org.autojs.autojs.util.RhinoUtils.withRhinoContext
|
import org.autojs.autojs.util.RhinoUtils.withRhinoContext
|
||||||
import org.mozilla.javascript.BaseFunction
|
import org.mozilla.javascript.BaseFunction
|
||||||
import org.mozilla.javascript.BoundFunction
|
import org.mozilla.javascript.BoundFunction
|
||||||
@@ -23,7 +24,7 @@ class RootAutomatorNativeObject(scriptRuntime: ScriptRuntime, waitForReady: Any?
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
super.exportAsJSClass(MAX_PROTOTYPE_ID, this, false)
|
RhinoUtils.initNativeObjectPrototype(this)
|
||||||
defineProperty("__ra__", mRootAutomatorObject, READONLY or DONTENUM or PERMANENT)
|
defineProperty("__ra__", mRootAutomatorObject, READONLY or DONTENUM or PERMANENT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import org.autojs.autojs.runtime.api.StringReadable
|
|||||||
import org.autojs.autojs.runtime.api.augment.Augmentable
|
import org.autojs.autojs.runtime.api.augment.Augmentable
|
||||||
import org.autojs.autojs.runtime.api.augment.colors.Colors.parseRelativePercentage
|
import org.autojs.autojs.runtime.api.augment.colors.Colors.parseRelativePercentage
|
||||||
import org.autojs.autojs.runtime.exception.WrappedIllegalArgumentException
|
import org.autojs.autojs.runtime.exception.WrappedIllegalArgumentException
|
||||||
|
import org.autojs.autojs.util.RhinoUtils
|
||||||
import org.autojs.autojs.util.RhinoUtils.NOT_CONSTRUCTABLE
|
import org.autojs.autojs.util.RhinoUtils.NOT_CONSTRUCTABLE
|
||||||
import org.autojs.autojs.util.RhinoUtils.newBaseFunction
|
import org.autojs.autojs.util.RhinoUtils.newBaseFunction
|
||||||
import org.autojs.autojs.util.StringUtils.uppercaseFirstChar
|
import org.autojs.autojs.util.StringUtils.uppercaseFirstChar
|
||||||
@@ -23,7 +24,7 @@ import org.mozilla.javascript.Scriptable
|
|||||||
class ColorNativeObject @JvmOverloads constructor(color: Any? = BLACK) : NativeObject(), StringReadable {
|
class ColorNativeObject @JvmOverloads constructor(color: Any? = BLACK) : NativeObject(), StringReadable {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
super.exportAsJSClass(MAX_PROTOTYPE_ID, this, false)
|
RhinoUtils.initNativeObjectPrototype(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val mProxyTowardsNames by lazy {
|
private val mProxyTowardsNames by lazy {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import org.autojs.autojs.runtime.api.augment.Augmentable
|
|||||||
import org.autojs.autojs.runtime.api.augment.continuation.Continuation
|
import org.autojs.autojs.runtime.api.augment.continuation.Continuation
|
||||||
import org.autojs.autojs.runtime.api.augment.continuation.Creator
|
import org.autojs.autojs.runtime.api.augment.continuation.Creator
|
||||||
import org.autojs.autojs.runtime.exception.WrappedIllegalArgumentException
|
import org.autojs.autojs.runtime.exception.WrappedIllegalArgumentException
|
||||||
|
import org.autojs.autojs.util.RhinoUtils
|
||||||
import org.autojs.autojs.util.RhinoUtils.UNDEFINED
|
import org.autojs.autojs.util.RhinoUtils.UNDEFINED
|
||||||
import org.autojs.autojs.util.RhinoUtils.coerceIntNumber
|
import org.autojs.autojs.util.RhinoUtils.coerceIntNumber
|
||||||
import org.autojs.autojs.util.RhinoUtils.coerceLongNumber
|
import org.autojs.autojs.util.RhinoUtils.coerceLongNumber
|
||||||
@@ -305,7 +306,7 @@ class Http(scriptRuntime: ScriptRuntime) : Augmentable(scriptRuntime) {
|
|||||||
private class ResponseBodyNativeObject(val resBody: ResponseBody, val responseWrapper: ResponseWrapper) : NativeObject() {
|
private class ResponseBodyNativeObject(val resBody: ResponseBody, val responseWrapper: ResponseWrapper) : NativeObject() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
super.exportAsJSClass(MAX_PROTOTYPE_ID, this, false)
|
RhinoUtils.initNativeObjectPrototype(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object : FlexibleArray() {
|
companion object : FlexibleArray() {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.autojs.autojs.extension.AnyExtensions.isJsNullish
|
|||||||
import org.autojs.autojs.extension.AnyExtensions.jsBrief
|
import org.autojs.autojs.extension.AnyExtensions.jsBrief
|
||||||
import org.autojs.autojs.extension.FlexibleArray
|
import org.autojs.autojs.extension.FlexibleArray
|
||||||
import org.autojs.autojs.runtime.api.StringReadable
|
import org.autojs.autojs.runtime.api.StringReadable
|
||||||
|
import org.autojs.autojs.util.RhinoUtils
|
||||||
import org.autojs.autojs.util.RhinoUtils.UNDEFINED
|
import org.autojs.autojs.util.RhinoUtils.UNDEFINED
|
||||||
import org.autojs.autojs.util.RhinoUtils.coerceString
|
import org.autojs.autojs.util.RhinoUtils.coerceString
|
||||||
import org.autojs.autojs.util.RhinoUtils.js_json_parse
|
import org.autojs.autojs.util.RhinoUtils.js_json_parse
|
||||||
@@ -35,7 +36,7 @@ class StorageNativeObject(@JvmField val name: String) : NativeObject(), StringRe
|
|||||||
)
|
)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
super.exportAsJSClass(MAX_PROTOTYPE_ID, this, false)
|
RhinoUtils.initNativeObjectPrototype(this)
|
||||||
defineProperty("name", name, PERMANENT)
|
defineProperty("name", name, PERMANENT)
|
||||||
defineProperty("size", { storage.size() }, null, PERMANENT)
|
defineProperty("size", { storage.size() }, null, PERMANENT)
|
||||||
defineFunctionProperties(mFunctionNames, Getter::class.java, PERMANENT)
|
defineFunctionProperties(mFunctionNames, Getter::class.java, PERMANENT)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.autojs.autojs.extension.ArrayExtensions.toNativeArray
|
|||||||
import org.autojs.autojs.extension.FlexibleArray.Companion.ensureArgumentsAtMost
|
import org.autojs.autojs.extension.FlexibleArray.Companion.ensureArgumentsAtMost
|
||||||
import org.autojs.autojs.extension.FlexibleArray.Companion.ensureArgumentsIsEmpty
|
import org.autojs.autojs.extension.FlexibleArray.Companion.ensureArgumentsIsEmpty
|
||||||
import org.autojs.autojs.runtime.api.StringReadable
|
import org.autojs.autojs.runtime.api.StringReadable
|
||||||
|
import org.autojs.autojs.util.RhinoUtils
|
||||||
import org.autojs.autojs.util.RhinoUtils.NOT_CONSTRUCTABLE
|
import org.autojs.autojs.util.RhinoUtils.NOT_CONSTRUCTABLE
|
||||||
import org.autojs.autojs.util.RhinoUtils.newBaseFunction
|
import org.autojs.autojs.util.RhinoUtils.newBaseFunction
|
||||||
import org.mozilla.javascript.Context
|
import org.mozilla.javascript.Context
|
||||||
@@ -26,7 +27,7 @@ class MorseCodeNativeObject(val parser: MorseCodeParser) : NativeObject(), Strin
|
|||||||
)
|
)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
super.exportAsJSClass(MAX_PROTOTYPE_ID, this, false)
|
RhinoUtils.initNativeObjectPrototype(this)
|
||||||
defineFunctionProperties(mFunctionNames, javaClass, PERMANENT)
|
defineFunctionProperties(mFunctionNames, javaClass, PERMANENT)
|
||||||
defineProperty(StringReadable.KEY, newBaseFunction(StringReadable.KEY, { toStringReadable() }, NOT_CONSTRUCTABLE), READONLY or DONTENUM or PERMANENT)
|
defineProperty(StringReadable.KEY, newBaseFunction(StringReadable.KEY, { toStringReadable() }, NOT_CONSTRUCTABLE), READONLY or DONTENUM or PERMANENT)
|
||||||
defineProperty("pattern", { parser.pattern.toNativeArray() }, null, PERMANENT)
|
defineProperty("pattern", { parser.pattern.toNativeArray() }, null, PERMANENT)
|
||||||
|
|||||||
@@ -1310,7 +1310,7 @@ object FileUtils {
|
|||||||
/** Matroska Video, known for supporting multiple video, audio, subtitle tracks. */
|
/** Matroska Video, known for supporting multiple video, audio, subtitle tracks. */
|
||||||
MKV("mkv", TypeDataHolder.VIDEO),
|
MKV("mkv", TypeDataHolder.VIDEO),
|
||||||
|
|
||||||
/** QuickTime Movie format, native to Apple’s QuickTime player. */
|
/** QuickTime Movie format, native to Apple's QuickTime player. */
|
||||||
MOV("mov", TypeDataHolder.VIDEO),
|
MOV("mov", TypeDataHolder.VIDEO),
|
||||||
|
|
||||||
/** Windows Media Video, a series of video codecs and their corresponding video coding formats. */
|
/** Windows Media Video, a series of video codecs and their corresponding video coding formats. */
|
||||||
@@ -1526,7 +1526,7 @@ object FileUtils {
|
|||||||
/** TMPGEnc Video Editor project. */
|
/** TMPGEnc Video Editor project. */
|
||||||
TPR("tpr", TypeDataHolder.VIDEO),
|
TPR("tpr", TypeDataHolder.VIDEO),
|
||||||
|
|
||||||
/** Windows Media, another format for Microsoft’s video system. */
|
/** Windows Media, another format for Microsoft's video system. */
|
||||||
WM("wm", TypeDataHolder.VIDEO),
|
WM("wm", TypeDataHolder.VIDEO),
|
||||||
|
|
||||||
/** Windows Media Player format. */
|
/** Windows Media Player format. */
|
||||||
|
|||||||
@@ -83,6 +83,11 @@ object RhinoUtils {
|
|||||||
ScriptableObject.getObjectPrototype(standardObjects)
|
ScriptableObject.getObjectPrototype(standardObjects)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
val arrayPrototype: Scriptable by lazy {
|
||||||
|
ScriptableObject.getArrayPrototype(standardObjects)
|
||||||
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
val functionPrototype: Scriptable by lazy {
|
val functionPrototype: Scriptable by lazy {
|
||||||
standardObjects["Function"].let {
|
standardObjects["Function"].let {
|
||||||
@@ -816,17 +821,32 @@ object RhinoUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun newNativeObject() = NativeObject().also {
|
fun initNativeObjectPrototype(o: NativeObject): NativeObject {
|
||||||
it.prototype = objectPrototype
|
// val cx = ContextWrapper.getCurrentContext()
|
||||||
|
// try {
|
||||||
|
// val tmpScope: Scriptable = cx.initStandardObjects()
|
||||||
|
// NativeObject.init(tmpScope, false)
|
||||||
|
// o.prototype = tmpScope.get("Object", tmpScope) as Scriptable
|
||||||
|
// } finally {
|
||||||
|
// Context.exit()
|
||||||
|
// }
|
||||||
|
return o.apply { prototype = objectPrototype }
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@JvmOverloads
|
fun initNativeArrayPrototype(a: NativeArray): NativeArray {
|
||||||
fun newNativeArray(lengthArg: Long = 0) = NativeArray(lengthArg).also { it.exportAsJSClass(NativeArray.MAX_PROTOTYPE_ID, it, false) }
|
return a.apply { prototype = arrayPrototype }
|
||||||
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun newNativeArray(array: Array<Any?>) = NativeArray(array).also { it.exportAsJSClass(NativeArray.MAX_PROTOTYPE_ID, it, false) }
|
fun newNativeObject() = initNativeObjectPrototype(NativeObject())
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JvmOverloads
|
||||||
|
fun newNativeArray(lengthArg: Long = 0) = initNativeArrayPrototype(NativeArray(lengthArg))
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun newNativeArray(array: Array<Any?>) = initNativeArrayPrototype(NativeArray(array))
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun hashCodeOfScriptable(other: Any?): Int? {
|
fun hashCodeOfScriptable(other: Any?): Int? {
|
||||||
if (other !is Scriptable) return null
|
if (other !is Scriptable) return null
|
||||||
|
|||||||
Binary file not shown.
@@ -56,6 +56,8 @@ import androidx.fragment.app.DialogFragment;
|
|||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -829,6 +831,7 @@ public class ColorPickerDialog extends DialogFragment implements ColorPickerView
|
|||||||
// region Builder
|
// region Builder
|
||||||
|
|
||||||
@IntDef({TYPE_CUSTOM, TYPE_PRESETS})
|
@IntDef({TYPE_CUSTOM, TYPE_PRESETS})
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface DialogType {
|
public @interface DialogType {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,12 +18,17 @@ package com.jaredrummler.android.colorpicker;
|
|||||||
|
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The shape of the color preview
|
* The shape of the color preview
|
||||||
*/
|
*/
|
||||||
@IntDef({ ColorShape.SQUARE, ColorShape.CIRCLE }) public @interface ColorShape {
|
@IntDef({ColorShape.SQUARE, ColorShape.CIRCLE})
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
public @interface ColorShape {
|
||||||
|
|
||||||
int SQUARE = 0;
|
int SQUARE = 0;
|
||||||
|
|
||||||
int CIRCLE = 1;
|
int CIRCLE = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user