To support XObject.inherited we need to attach some
information to each of our methods. We will do this by modifying
XClass.merge to check each property it adds to the
prototype. If the property is a function, it adds a _name
property to the function. If the function overrides a base class
method, it adds a _inherited property which is a
reference to the overridden method. Here is the new merge
funciton.
01: merge: function(target, properties, superclass) {
02: for ( var property in properties ) {
03: if ( !this.filterList.contains(property) ) {
04: var value = properties[property];
05: target[property] = value;06: if ( value && typeof(value) == "function" ) {
07: value._name = property;08: var sc = superclass;
09: while ( sc ) {
10: scprop = sc.prototype[property];11: if ( scprop && typeof(scprop) == "function" ) {
12: value._inherited = scprop;
13: break;
14: }15: else {
16: sc = sc.prototype.superclass;
17: }
18: }
19: }
20: }
21: }
22: }
Next we will see how the inherited method is used.