Update of /cvsroot/qooxdoo/qooxdoo/source/script/core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30554/source/script/core
Modified Files:
Tag: renderer
QxExtend.js
Log Message:
Improved error output of addProperty
Index: QxExtend.js
===================================================================
RCS file: /cvsroot/qooxdoo/qooxdoo/source/script/core/QxExtend.js,v
retrieving revision 1.7.2.108
retrieving revision 1.7.2.109
diff -u -d -r1.7.2.108 -r1.7.2.109
--- QxExtend.js 27 Jan 2006 15:32:02 -0000 1.7.2.108
+++ QxExtend.js 30 Jan 2006 12:11:47 -0000 1.7.2.109
@@ -47,7 +47,7 @@
if (typeof vClassName != QxConst.TYPEOF_STRING) {
throw new Error("Extend: Missing or malformed className: " + vClassName);
};
-
+
// build helper function
// this omits the initial constructor call while inherit properties
var f = new Function;
@@ -318,11 +318,11 @@
Function.prototype._createProperty = function(p)
{
if(typeof p != QxConst.TYPEOF_OBJECT) {
- throw new Error("Param should be an object!");
+ throw new Error("AddProperty: Param should be an object!");
};
if (QxUtil.isInvalid(p.name)) {
- throw new Error("Malformed input parameters: name needed!");
+ throw new Error("AddProperty: Malformed input parameters: name needed!");
};
// building shorter prototype access
@@ -342,45 +342,45 @@
if (QxUtil.isInvalidBoolean(p.allowMultipleArguments)) {
p.allowMultipleArguments = false;
};
-
-
+
+
if (typeof p.type == QxConst.TYPEOF_STRING) {
- p.hasType = true;
- }
+ p.hasType = true;
+ }
else if (typeof p.type != QxConst.TYPEOF_UNDEFINED) {
- throw new Error("Invalid type definition for property " + p.name + ": " + p.type);
+ throw new Error("AddProperty: Invalid type definition for property " + p.name + ": " + p.type);
}
else {
p.hasType = false;
};
if (typeof p.instance == QxConst.TYPEOF_STRING) {
- p.hasInstance = true;
- }
+ p.hasInstance = true;
+ }
else if (typeof p.instance != QxConst.TYPEOF_UNDEFINED) {
- throw new Error("Invalid instance definition for property " + p.name + ": " + p.instance);
+ throw new Error("AddProperty: Invalid instance definition for property " + p.name + ": " + p.instance);
}
else {
p.hasInstance = false;
};
if (typeof p.classname == QxConst.TYPEOF_STRING) {
- p.hasClassName = true;
- }
+ p.hasClassName = true;
+ }
else if (typeof p.classname != QxConst.TYPEOF_UNDEFINED) {
- throw new Error("Invalid classname definition for property " + p.name + ": " + p.classname);
+ throw new Error("AddProperty: Invalid classname definition for property " + p.name + ": " + p.classname);
}
else {
p.hasClassName = false;
};
-
-
-
-
+
+
+
+
p.hasConvert = QxUtil.isValidFunction(p.convert);
@@ -401,8 +401,8 @@
var changeKey = QxConst.INTERNAL_CHANGE + p.method;
var modifyKey = QxConst.INTERNAL_MODIFY + p.implMethod;
var checkKey = QxConst.INTERNAL_CHECK + p.implMethod;
-
- if (!QxSetter[p.name])
+
+ if (!QxSetter[p.name])
{
QxSetter[p.name] = QxConst.INTERNAL_SET + p.method;
QxGetter[p.name] = QxConst.INTERNAL_GET + p.method;
@@ -450,8 +450,8 @@
pp[QxConst.INTERNAL_TOGGLE + p.method] = function(newValue) {
return this[QxConst.INTERNAL_SET + p.method](!this[valueKey]);
};
- };
-
+ };
+
if (p.allowMultipleArguments || p.hasConvert || p.hasInstance || p.hasClassName || p.hasPossibleValues || p.hasUnitDetection || p.addToQueue || p.addToQueueRuntime || p.addToStateQueue)
{
// building setFoo(): Setup new value, do type and change detection, converting types, call unit detection, ...
@@ -461,7 +461,7 @@
if (p.allowMultipleArguments && arguments.length > 1) {
newValue = QxUtil.convertArgumentsToArray(arguments);
};
-
+
// support converter methods
if (p.hasConvert)
{
@@ -474,53 +474,53 @@
throw new Error("Attention! Could not convert new value for " + p.name + ": " + newValue + ": " + ex);
};
};
-
+
var oldValue = this[valueKey];
-
+
if (newValue === oldValue) {
return newValue;
};
-
+
if (!(p.allowNull && newValue == null))
{
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 (this[checkKey])
{
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 (this[modifyKey])
{
@@ -536,12 +536,12 @@
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);
@@ -549,19 +549,19 @@
else if (p.addToQueueRuntime) {
this.addToQueueRuntime(p.name);
};
-
+
// Auto state queue addition support
if (p.addToStateQueue) {
this._addToGlobalStateQueue();
};
-
+
// Create Event
if (this.hasEventListeners && this.hasEventListeners(changeKey))
{
var vEvent = new QxDataEvent(changeKey, newValue, oldValue, false);
-
+
vEvent.setTarget(this);
-
+
try
{
this.dispatchEvent(vEvent, true);
@@ -571,7 +571,7 @@
throw new Error("Property " + p.name + " modified: Failed to dispatch change event: " + ex);
};
};
-
+
return newValue;
};
}
@@ -581,41 +581,41 @@
pp[QxConst.INTERNAL_SET + p.method] = function(newValue)
{
// this.debug("Fast Setter: " + p.name);
-
+
var oldValue = this[valueKey];
-
+
if (newValue === oldValue) {
return newValue;
};
-
+
if (!(p.allowNull && newValue == null))
{
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);
};
};
-
+
// Allow to check and transform the new value before storage
if (this[checkKey])
{
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 (this[modifyKey])
{
@@ -631,14 +631,14 @@
return this.error("Modification of property \"" + p.name + "\" failed with exception (" + ex + ")", modifyKey);
};
};
-
+
// Create Event
if (this.hasEventListeners && this.hasEventListeners(changeKey))
{
var vEvent = new QxDataEvent(changeKey, newValue, oldValue, false);
-
+
vEvent.setTarget(this);
-
+
try
{
this.dispatchEvent(vEvent, true);
@@ -648,9 +648,9 @@
throw new Error("Property " + p.name + " modified: Failed to dispatch change event: " + ex);
};
};
-
+
return newValue;
- };
+ };
};
// building user configured get alias for property
@@ -669,7 +669,7 @@
Function.prototype.addProperty = function(p)
{
QxPropertyCounter++;
-
+
this._createProperty(p);
// add property to list
|