The mode of Overloading :typed or non-typed.true for typed , false for non-typed
an array containing the overloads.
the overloaded function
types), and the second is for the function itself.xTyped or xNonTyped.
var Add = Function.create(xNonTyped , [
function(a,b){return a + b;},
function(a,b,c){return a + b + c;}
]);
the constructor function of the type (either native or custom)
the type list object to be passed to Function.create
xSelf to point to the class being created.
var Add = Function.create(xTyped , [
types(Number,Number),
function(a,b) { return a + b}
]);
the custom constructor function to be stamped for recognition
var Complex = function(re , img) {
this.re = re; this.img = img;}
classing.xStamp(Complex);
var Add = Function.create(xTyped , [
types(Complex,Complex),function(Z,W){
return new Complex(Z.re + W.re,Z.img + W.img);
}
]);
The defintion of the class
the created class
defintion object are one, two or all of the following: private,protected and public(which are the access modifiers).
var Person = classing.Class({
public : { name : "John Doe"}
});
the component to be marked static.
an object wrapping the component and marked with an isStatic property.
var Person = Class({
public: {
counter : Static(0),
Construct: function(){Person.counter++;}
}
})
The function to be marked as final
The marked function
var Visitor = Class({
private : { id : null},
public: {
Construct : function() { this.id = Date.now();},
getId : Final(function(){return this.id;})
}
})
var Infertile = classing.Final.Class({
public : {name : null}
})
The function to be marked abstract.
The marked function.
method must be empty. if it's an overloaded function, all the instances must have empty bodies.
var Child = classing.Abstract.Class({
public: { Play : Abstract(function(){}) }
});
Abstract function.
var Shape = classing.Abstract.Class({
public : { Area : Abstract(function(){})}
});
The parent class
base keyword.
var Child = classing.Class.Extends(Parent)({
public : {
newFunc : function(){ return "function of child"; }
}
});
The defintion of the interface.
The Object represinting the interface
defintion object is a function with empty body. if it's an overloaded function, all the instances must have empty bodies.
var IPayable = classing.Interface({
getPaid : function()
})
an interface to be implemented.
Class.Extends(...).Implements(...)
var Employee = classing.Class.Implements(IPayable)({
public: {getPaid : function(){return "$5000.00"}}
})
The Class or Interface to check if the object is instance of it.
true of the object is instance of ancstor. false otherwise.
Object (which is exaclty every object you make) will have the instanceOf method.
var IVoid = classing.Interface({ func : function(){} });
var Parent = classing.Class({});
var Child = classing.Class.Extends(Parent).Implements(IVoid)({
public : { func : function(){return "void";} }
});
var obj = new Child();
obj.instanceOf(Child); //true
obj.instanceOf(Parent); //true
obj.instanceOf(IVoid); //true;
obj.instanceOf(Object); //true;