Merge pull request #958 from jareguo/temp

still checking class inheritance by using $super in JSB
This commit is contained in:
Jare Guo
2016-07-27 11:21:50 +08:00
committed by GitHub
3 changed files with 18 additions and 11 deletions
+1
View File
@@ -244,6 +244,7 @@ var ProgressBar = cc.Class({
default: 1,
type: 'Float',
range: [0, 1, 0.1],
slide: true,
tooltip: 'i18n:COMPONENT.progress.progress',
notify: function() {
this._updateBarStatus();
+17 -6
View File
@@ -338,9 +338,14 @@ cc.isChildClassOf = function (subclass, superclass) {
return true;
}
for (;;) {
var proto = subclass.prototype; // binded function do not have prototype
var dunderProto = proto && Object.getPrototypeOf(proto);
subclass = dunderProto && dunderProto.constructor;
if (CC_JSB && subclass.$super) {
subclass = subclass.$super;
}
else {
var proto = subclass.prototype; // binded function do not have prototype
var dunderProto = proto && Object.getPrototypeOf(proto);
subclass = dunderProto && dunderProto.constructor;
}
if (!subclass) {
return false;
}
@@ -356,8 +361,13 @@ cc.isChildClassOf = function (subclass, superclass) {
function getInheritanceChain (klass) {
var chain = [];
for (;;) {
var dunderProto = Object.getPrototypeOf(klass.prototype);
klass = dunderProto && dunderProto.constructor;
if (CC_JSB && klass.$super) {
klass = klass.$super;
}
else {
var dunderProto = Object.getPrototypeOf(klass.prototype);
klass = dunderProto && dunderProto.constructor;
}
if (!klass) {
break;
}
@@ -1068,6 +1078,7 @@ function parseAttributes (attrs, className, propName) {
parseSimpleAttr('multiline', 'boolean', {multiline: true});
parseSimpleAttr('readonly', 'boolean', {readonly: true});
parseSimpleAttr('tooltip', 'string');
parseSimpleAttr('slide', 'boolean');
}
if (attrs.url) {
@@ -1105,7 +1116,7 @@ function parseAttributes (attrs, className, propName) {
if (range) {
if (Array.isArray(range)) {
if (range.length >= 2) {
result.push(Attr.Range(range[0], range[1]));
result.push({ min: range[0], max: range[1], step: range[2] });
}
else if (CC_DEV) {
cc.error('The length of range array must be 2');
-5
View File
@@ -351,10 +351,6 @@ function RawType (typename) {
};
}
function Range (min, max) {
return { min: min, max: max };
}
module.exports = {
attr: attr,
getClassAttrs: getClassAttrs,
@@ -366,5 +362,4 @@ module.exports = {
ObjectType: ObjectType,
RawType: RawType,
ScriptUuid: {}, // the value will be represented as a uuid string
Range: Range
};