classified dd and finalized multi-inheritance
[xynt.git] / xynt-base.js
1 function Extends(sub)
2 {
3     var proto;
4     thinF = function(){};
5     inh = new thinF();
6     inh.xynt_sup = [];
7     inh.xynt_sup_cl = [];
8
9     console.log("INIZIO EXT");
10
11     var multi = function(sub, super, is_last)
12     {
13         var proto = super.prototype;
14
15         for (var f in proto) {
16             if (f == "xynt_sup" || f == "xynt_sup_cl")
17                 continue;
18
19             console.log("LOOP: "+f);
20             if( f != "constructor" && typeof(proto[f]) == "function" && !is_last){
21                 console.log("M_FU: "+proto['name']+"  F: "+f);
22                 // sub[f] = proto[f];
23                 sub[f] = function(){
24                     console.log("INFU PR: " + proto['name'] + " FUNC: "+f+" THIS: " + this);
25                     return proto[f].apply(this,arguments);
26                 }
27             }
28             else {
29                 console.log("M_PR: "+proto.name+"  A: "+f+" FUN: "+proto[f]);
30                 sub[f] = proto[f];
31             }
32         }
33     }
34
35     for( var i=1; i < arguments.length ; i++){
36         multi(inh, arguments[i], false);
37         inh.xynt_sup.push(arguments[i].prototype);
38         inh.xynt_sup_cl.push(arguments[i]);
39     }
40
41     multi(inh, sub, true);
42     inh.super = function(cl, method) {
43         return this.xynt_sup_cl[cl].method.apply(this,arguments);
44     }
45     sub.prototype = inh;
46
47     console.log(sub.prototype.xynt_sup);
48     console.log(sub.prototype.xynt_sup_cl);
49 }