}
}
-function Extends(sub, super)
+function Extends_simple(sub, super)
{
var thinF = function(){};
thinF.prototype = super.prototype;
sub.prototype = tmp;
}
-Extends(Caino, Adamo);
+Extends_simple(Caino, Adamo);
var c = new Caino();
-console.log("A"+c.alupa);
-console.log("G"+c.gojira);
-console.log("U"+c.unko);
+console.log("A "+c.alupa);
+console.log("G "+c.gojira);
+console.log("U "+c.unko);
c.pname();
c.pname2();
+function PreA() {
+ this.a_din = "adamo";
+}
+PreA.prototype = {
+ a_attr: "a attr content",
+ name: "PreA",
-if (0 == 1) {
-var thinF = function(){};
-thinF.prototype = super.prototype;
-sub.prototype = new thinF();
-sub.prototype.constructor = sub;
-sub.super = super.prototype;
-if( super.prototype.constructor == Object.prototype.constructor ){
- super.prototype.constructor = super;
+ a_func: function()
+ {
+ console.log("A_NAME: "+this.a_din);
+ console.log("A_ATTR: "+this.a_attr);
+ }
}
-var a = new Adamo();
-var c = new Caino();
+function A() {
+ PreA.call(this);
+}
+A.prototype = {
+ name: "A"
+}
+Extends(A, PreA);
+function B() {
+ this.b_din = "bonobo";
+}
-c.pname();
+B.prototype = {
+ name: "B",
+ b_attr: "b attr content",
+
+ b_func: function()
+ {
+ console.log("B_NAME: "+this.b_din);
+ console.log("B_ATTR: "+this.b_attr);
+ }
+}
+
+function C() {
+ this.c_din = "canuca";
}
-/*
+C.prototype = {
+ name: "C",
+ c_attr: "c attr content",
+
+ c_func: function()
+ {
+ console.log("C_NAME: "+this.c_din);
+ console.log("C_ATTR: "+this.c_attr);
+ }
+}
+
+
+function Summo() {
+ this.s_name = "caino";
+ A.call(this);
+ B.call(this);
+ C.call(this);
-var thinF = function(){};
-thinF.prototype = super.prototype;
-sub.prototype = new thinF();
+}
+
+Summo.prototype = {
+ name: "Summo",
+ s_attr: null,
+
+ s_func: function()
+ {
+ this.a_func();
+ this.b_func();
+ this.c_func();
+ console.log("name: "+this.name);
+ }
+}
+
+Extends(Summo, A, B, C);
+
+function Extends(sub)
+{
+ var supers = [];
+
+ thinF = function(){};
+ tmp = new thinF();
+
+ console.log("INIZIO EXT");
+
+ var multi = function(sub, super, is_last)
+ {
+ var proto = super.prototype;
+
+ for (var f in proto) {
+ console.log("LOOP: "+f);
+ if( f != "constructor" && typeof(proto[f]) == "function" && is_last){
+ console.log("PR: "+proto['name']+" F: "+f);
+ // sub[f] = proto[f];
+ sub[f] = function(){
+ console.log("INFU PR: " + proto['name'] + " FUNC: "+f);
+ return proto[f].apply(this,arguments);
+ }
+ }
+ else {
+ console.log("PR: "+proto.name+" A: "+f+" FUN: "+proto[f]);
+ sub[f] = proto[f];
+ }
+ }
+ }
+
+ for( var i=1; i < arguments.length ; i++){
+ console.log("INIZIO LOOP");
+ multi(tmp, arguments[i], false);
+ supers.push(arguments[i].prototype);
+ }
+ multi(tmp, sub, true);
+ sub.prototype = tmp;
+}
-05. sub.prototype.constructor = sub;
-06. sub.super = super.prototype;
-07. if( super.prototype.constructor == Object.prototype.constructor ){
-08. super.prototype.constructor = super;
-*/
+s_ist = new Summo();
+s_ist.s_func();
</script>