Skip to content

Commit

Permalink
fix(autojs): script bridges convert boolean to Boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
hyb1996 committed Apr 25, 2018
1 parent 55f2e7b commit a6bc3b2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions autojs/src/main/assets/modules/__bridges__.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,26 @@ bridges.call = function (func, target, args) {
return func.apply(target, arr);
};

/*
Java Object: 拥有getClass, notify, toString, hashCode, equals等函数
没有prototype, __proto__, constructor等属性
使用obj.xxx时如果没有xxx属性可能会直接抛出异常而不是undefined???
只能使用in关键字来判断某个属性是否存在(但in关键字不能用于JavaScript基本类型)
typeof()返回'object'
instanceof Object为false
*/
function wrap(value){
if(!(value instanceof Object && 'getClass' in value && util.isFunction(value.getClass))){
if(!(typeof(value) == 'object' && value.getClass && util.isFunction(value.getClass))){
return value;
}
var c = value.getClass();
if(!('getName' in c && util.isFunction(c.getName))){
if(!(c.getName && util.isFunction(c.getName))){
return value;
}
var name = c.getName();
if(name == 'java.lang.Boolean'){
return Boolean(value);
return value == true;
}
//TODO: is is necessary?
if(name == 'java.lang.Integer' || name == 'java.lang.Long' || name == 'java.lang.Double'
Expand Down

0 comments on commit a6bc3b2

Please sign in to comment.