Repository navigation
Conversation
- Rhino 1.8.1 -> 1.9.2,适配新的 TypeInfo 类型系统(wrap / wrapAsJavaObject 签名变更) - 新增 InjectedNativeJavaObject、SimpleTypeInfo,View 对象统一包装后可读写布局属性 - ProxyObject / ProxyJavaObject / NativeJavaObjectWithPrototype / BindingNativeJavaObject 同步重构,移除 VMBridge_custom - 新增 AttrSupport 接口,13 个 Js* 控件实现,经由 ViewExtras / ViewAttributes 读写属性 - JsSpinner 支持下拉最大高度、条目高度以及选中态/普通态文字与背景色配置 - v6-api 的 ui.ts 暴露控件属性接口
Rhino 1.9.2 把 WrapFactory 调用链统一到 wrap(..., TypeInfo) -> wrapAsJavaObject(..., TypeInfo),且 VMBridge 整套被移除。原实现为此新增 InjectedNativeJavaObject 在 get() 里手写反射分派 ViewPrototype,并重写 wrap(TypeInfo),带来两类问题: - 手写 get() 在 prototype 非 null 时对任意属性返回 BaseFunction, has()/get() 不一致、拼错属性静默失败;Method.invoke 未做 JS->Java 参数转换且漏 catch IllegalArgumentException,存在崩溃路径。 - 重写 wrap(TypeInfo) 绕过了 AndroidContextFactory.WrapFactory 的 wrap(..., Class) 重载,导致 UiObject / UiObjectCollection 的 UiObjectProxy / bridges.asArray 包装完全失效。 改为最小适配: - AndroidContextFactory.WrapFactory 把 UiObject 处理迁移到 TypeInfo 签名。 - RhinoJavaScriptEngine.WrapFactory 只重写 wrapAsJavaObject(TypeInfo), View 交给 ViewExtras.getNativeView()(NativeJavaObjectWithPrototype 的 prototype 链);UI 控件方法由 AttrSupport 的 Java 默认方法暴露, 属性分派与参数转换交回 Rhino LiveConnect。 - 删除 InjectedNativeJavaObject 及所有 WrapFactory 调试日志。 另外: - VolatileDispose 增加 mSet 标志,使 setAndNotify(null) 不会因 notify 早于 blockedGet 而丢失唤醒(ui.run 竞态),无需把值改回 true。 - ui.ts 移除 ui.run 的耗时调试日志,保留 setAndNotify(null)。 注意:view.text = 123 这类数字赋值不再自动转字符串,回归 Rhino 原生 JavaBean setter 行为;如依赖该便利行为需另加专门 setter。
从合并后的 setup-v7 取回 3 处只存在于主分支、但落在本 PR 改动 范围内的修复(对应 f8d5722b / 4ca651ee): - ViewExtras: 静态 ResourceParser 改 WeakReference,避免脚本退出后 仍静态强持有 ScriptRuntime 资源;按 view 绑定创建时的 parser, 避免后启动脚本覆盖静态 parser 导致旧脚本控件属性解析落到别的 运行时;setAttr 统一走 getViewAttributes(view) - ProxyObject: 属性赋值日志不再打印 value,避免 token 等敏感值进 logcat - NativeJavaObjectWithPrototype: Rhino 1.9.2 下 JsTextView 同时有 text()/text(CharSequence),text 被暴露成 NativeJavaMethod, super.put() 只写进 JS 属性表会被遮蔽;特判 text + TextView 直接 落到 TextView.setText,恢复 view.text = "xxx" 属性赋值 ScriptRuntime.java 仅有 import 顺序与一行注释差异,无功能影响,不动。
ScriptRuntime.java 里残留 3 处 CustomToastView 引用(import / toastX 字段 / 构造函数初始化),是本分支从本地含 custom toast 的 树带进来的;而 CustomToastView.kt 属于 pr/custom-toast,上游基线 4c396b2 全树也没有该类。结果是纯上游单独合并本 PR 会因找不到 CustomToastView 而编译失败。 这里只移除这 3 处,使本 PR 完全不触碰 custom toast(该功能由 pr/custom-toast 单独提供)。保留 rhino/UI 属性注入相关的 ViewExtras.setResourceParser(...) 及 Scriptable import 的清理。
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| ErrorProne | 1 high |
| Security | 1 high |
🟢 Metrics 65 complexity · -3 duplication
Metric Results Complexity 65 Duplication -3
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
脚本引擎升级到 Rhino 1.9.2,并补齐新版本下 UI 控件属性赋值的兼容处理。
变更
兼容性