org.hisrc.jsonix.Jsonix.Class.js Maven / Gradle / Ivy
Jsonix.Class = function() {
var Class = function() {
this.initialize.apply(this, arguments);
};
var extended = {};
var empty = function() {
};
var parent, initialize, Type;
for (var i = 0, len = arguments.length; i < len; ++i) {
Type = arguments[i];
if (typeof Type == "function") {
// make the class passed as the first argument the superclass
if (i === 0 && len > 1) {
initialize = Type.prototype.initialize;
// replace the initialize method with an empty function,
// because we do not want to create a real instance here
Type.prototype.initialize = empty;
// the line below makes sure that the new class has a
// superclass
extended = new Type();
// restore the original initialize method
if (initialize === undefined) {
delete Type.prototype.initialize;
} else {
Type.prototype.initialize = initialize;
}
}
// get the prototype of the superclass
parent = Type.prototype;
} else {
// in this case we're extending with the prototype
parent = Type;
}
Jsonix.Util.extend(extended, parent);
}
Class.prototype = extended;
return Class;
};
© 2015 - 2024 Weber Informatics LLC | Privacy Policy