[Qooxdoo-commit] qooxdoo/source/script/core QxExtend.js,1.7.2.102,1.7.2.103
Brought to you by:
ecker,
martinwittemann
|
From: Sebastian W. <wp...@us...> - 2006-01-23 14:50:50
|
Update of /cvsroot/qooxdoo/qooxdoo/source/script/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30234 Modified Files: Tag: renderer QxExtend.js Log Message: Back to old version because new one was dramatically slower Index: QxExtend.js =================================================================== RCS file: /cvsroot/qooxdoo/qooxdoo/source/script/core/QxExtend.js,v retrieving revision 1.7.2.102 retrieving revision 1.7.2.103 diff -u -d -r1.7.2.102 -r1.7.2.103 --- QxExtend.js 23 Jan 2006 13:28:25 -0000 1.7.2.102 +++ QxExtend.js 23 Jan 2006 14:50:42 -0000 1.7.2.103 @@ -316,153 +316,6 @@ pp[QxConst.INTERNAL_SETDEFAULT + p.method] = null; }; - - - - - - -var QxProperties = -{ - advancedCheck : function(newValue, p) - { - if (!(newValue == null && p.allowNull)) - { - if (p.hasType && typeof newValue != p.type) { - return this.error("Attention! The value \"" + newValue + "\" is an invalid value for the property \"" + p.name + "\" which must be typeof \"" + p.type + "\" but is typeof \"" + typeof newValue + "\"!", QxConst.INTERNAL_SET + p.method); - }; - - if (p.hasInstance && !(newValue instanceof QxClasses[p.instance])) { - return this.error("Attention! The value \"" + newValue + "\" is an invalid value for the property \"" + p.name + "\" which must be an instance of \"" + p.instance + "\"!", QxConst.INTERNAL_SET + p.method); - }; - - if (p.hasClassName && newValue.classname != p.classname) { - return this.error("Attention! The value \"" + newValue + "\" is an invalid value for the property \"" + p.name + "\" which must be an object with the classname \"" + p.classname + "\"!", QxConst.INTERNAL_SET + p.method); - }; - - if (p.hasPossibleValues && newValue != null && !p.possibleValues.contains(newValue)) { - return this.error("Failed to save value for " + p.name + ". '" + newValue + "' is not a possible value!", QxConst.INTERNAL_SET + p.method); - }; - }; - }, - - userCheck : function(checkKey, newValue, oldValue, p) - { - // Allow to check and transform the new value before storage - if (typeof this[checkKey] == QxConst.TYPEOF_FUNCTION) - { - try - { - return this[checkKey](newValue, p); - } - catch(ex) - { - return this.error("Failed to check property " + p.name + ": " + ex, checkKey); - }; - }; - - return newValue; - }, - - storeValue : function(valueKey, modifyKey, newValue, oldValue, p) - { - // Store new value - this[valueKey] = newValue; - - // Check if there is a modifier implementation - if (typeof this[modifyKey] == QxConst.TYPEOF_FUNCTION) - { - try - { - var r = this[modifyKey](newValue, oldValue, p); - if (!r) { - return this.error("Modification of property \"" + p.name + "\" failed without exception (" + r + ")", modifyKey); - }; - } - catch(ex) - { - return this.error("Modification of property \"" + p.name + "\" failed with exception (" + ex + ")", modifyKey); - }; - }; - }, - - unitDetection : function(unitDetectionKey, newValue, p) - { - // Unit detection support - if (p.hasUnitDetection) { - this[unitDetectionKey](p, newValue); - }; - }, - - queueAdd : function(p) - { - // Auto queue addition support - if (p.addToQueue) { - this.addToQueue(p.name); - } - else if (p.addToQueueRuntime) { - this.addToQueueRuntime(p.name); - }; - - // Auto state queue addition support - if (p.addToStateQueue) { - this._addToGlobalStateQueue(); - }; - }, - - eventDispatch : function(changeKey, newValue, oldValue, p) - { - // Create Event - if (this instanceof QxTarget && this.hasEventListeners(changeKey)) - { - var ce = new QxDataEvent(changeKey, newValue, oldValue, false); - - ce.setTarget(this); - - try - { - this.dispatchEvent(ce, true); - } - catch(ex) - { - throw new Error("Property " + p.name + " modified: Failed to dispatch change event: " + ex); - }; - }; - }, - - applyConvert : function(newValue, p) - { - // support converter methods - if (p.hasConvert) - { - try - { - return p.convert.call(this, newValue, p); - } - catch(ex) - { - throw new Error("Attention! Could not convert new value for " + p.name + ": " + newValue + ": " + ex); - }; - }; - - return newValue; - }, - - multipleArguments : function(args, p) - { - // convert multiple arguments to array - if (p.allowMultipleArguments && args.length > 1) { - return QxUtil.convertArgumentsToArray(args); - }; - - return args[0]; - } -}; - - - - - Function.prototype._createProperty = function(p) { if(typeof p != QxConst.TYPEOF_OBJECT) { @@ -540,42 +393,11 @@ // apply default value pp[valueKey] = p.defaultValue; - - - - // building getFoo(): Returns current stored value pp[QxConst.INTERNAL_GET + p.method] = function() { return this[valueKey]; }; - // building setFoo(): Setup new value, do type and change detection, converting types, call unit detection, ... - pp[QxConst.INTERNAL_SET + p.method] = function(newValue) - { - var oldValue = this[valueKey]; - - newValue = QxProperties.multipleArguments.call(this, arguments, p); - newValue = QxProperties.applyConvert.call(this, newValue, p); - - if (newValue == oldValue) { - return newValue; - }; - - QxProperties.advancedCheck.call(this, newValue, p); - - newValue = QxProperties.userCheck.call(this, checkKey, newValue, oldValue, p); - - QxProperties.storeValue.call(this, valueKey, modifyKey, newValue, oldValue, p); - QxProperties.unitDetection.call(this, unitDetectionKey, newValue, p); - QxProperties.queueAdd.call(this, p); - QxProperties.eventDispatch.call(this, changeKey, newValue, oldValue, p); - - return newValue; - }; - - - - // building forceFoo(): Set (override) without do anything else pp[QxConst.INTERNAL_FORCE + p.method] = function(newValue) { return this[valueKey] = newValue; @@ -592,9 +414,130 @@ pp[QxConst.INTERNAL_TOGGLE + p.method] = function(newValue) { return this[QxConst.INTERNAL_SET + p.method](!this[valueKey]); }; - }; - - + }; + + // building setFoo(): Setup new value, do type and change detection, converting types, call unit detection, ... + pp[QxConst.INTERNAL_SET + p.method] = function(newValue) + { + // convert multiple arguments to array + if (p.allowMultipleArguments && arguments.length > 1) { + newValue = QxUtil.convertArgumentsToArray(arguments); + }; + + // support converter methods + if (p.hasConvert) + { + try + { + newValue = p.convert.call(this, newValue, p); + } + catch(ex) + { + throw new Error("Attention! Could not convert new value for " + p.name + ": " + newValue + ": " + ex); + }; + }; + + var oldValue = this[valueKey]; + + if (newValue == oldValue) { + return newValue; + }; + + if (!(newValue == null && p.allowNull)) + { + if (p.hasType && typeof newValue != p.type) { + return this.error("Attention! The value \"" + newValue + "\" is an invalid value for the property \"" + p.name + "\" which must be typeof \"" + p.type + "\" but is typeof \"" + typeof newValue + "\"!", QxConst.INTERNAL_SET + p.method); + }; + + if (p.hasInstance && !(newValue instanceof QxClasses[p.instance])) { + return this.error("Attention! The value \"" + newValue + "\" is an invalid value for the property \"" + p.name + "\" which must be an instance of \"" + p.instance + "\"!", QxConst.INTERNAL_SET + p.method); + }; + + if (p.hasClassName && newValue.classname != p.classname) { + return this.error("Attention! The value \"" + newValue + "\" is an invalid value for the property \"" + p.name + "\" which must be an object with the classname \"" + p.classname + "\"!", QxConst.INTERNAL_SET + p.method); + }; + + if (p.hasPossibleValues && newValue != null && !p.possibleValues.contains(newValue)) { + return this.error("Failed to save value for " + p.name + ". '" + newValue + "' is not a possible value!", QxConst.INTERNAL_SET + p.method); + }; + }; + + // Allow to check and transform the new value before storage + if (typeof this[checkKey] == QxConst.TYPEOF_FUNCTION) + { + try + { + newValue = this[checkKey](newValue, p); + + // Don't do anything if new value is indentical to old value + if (newValue == oldValue) { + return newValue; + }; + } + catch(ex) + { + return this.error("Failed to check property " + p.name + ": " + ex, checkKey); + }; + }; + + // Store new value + this[valueKey] = newValue; + + // Check if there is a modifier implementation + if (typeof this[modifyKey] == QxConst.TYPEOF_FUNCTION) + { + try + { + var r = this[modifyKey](newValue, oldValue, p); + if (!r) { + return this.error("Modification of property \"" + p.name + "\" failed without exception (" + r + ")", modifyKey); + }; + } + catch(ex) + { + return this.error("Modification of property \"" + p.name + "\" failed with exception (" + ex + ")", modifyKey); + }; + }; + + // Unit detection support + if (p.hasUnitDetection) { + this[unitDetectionKey](p, newValue); + }; + + // Auto queue addition support + if (p.addToQueue) { + this.addToQueue(p.name); + } + else if (p.addToQueueRuntime) { + this.addToQueueRuntime(p.name); + }; + + // Auto state queue addition support + if (p.addToStateQueue) { + this._addToGlobalStateQueue(); + }; + + // Create Event + if (this instanceof QxTarget && this.hasEventListeners(changeKey)) + { + var ce = new QxDataEvent(changeKey, newValue, oldValue, false); + + ce.setTarget(this); + + try + { + this.dispatchEvent(ce, true); + } + catch(ex) + { + throw new Error("Property " + p.name + " modified: Failed to dispatch change event: " + ex); + }; + + ce = null; + }; + + return newValue; + }; // building user configured get alias for property if (typeof p.getAlias == QxConst.TYPEOF_STRING) { |