--- /dev/null
+
+function Extends(sub)
+{
+ var proto;
+ thinF = function(){};
+ inh = new thinF();
+ inh.xynt_sup = [];
+ inh.xynt_sup_cl = [];
+
+ console.log("EXT START");
+
+ var multi = function(sub, super, is_last)
+ {
+ var proto = super.prototype;
+
+ for (var f in proto) {
+ if (f == "xynt_sup" || f == "xynt_sup_cl")
+ continue;
+
+ console.log("LOOP: "+f);
+ if( f != "constructor" && typeof(proto[f]) == "function" && !is_last){
+ console.log("M_FU: "+proto[f]+" F: "+f);
+ // sub[f] = proto[f];
+ sub[f] = function() {
+ // console.log("INFU PR: " + proto[f] + " FUNC: "+f+" THIS: " + this);
+ console.log("SIMPLE LOG");
+ return proto[f].apply(this,arguments);
+ }
+ }
+ else {
+ console.log("M_PR: "+proto.name+" A: "+f+" FUN: "+proto[f]);
+ sub[f] = proto[f];
+ }
+ }
+ }
+
+ for( var i=1; i < arguments.length ; i++){
+ multi(inh, arguments[i], false);
+ inh.xynt_sup.push(arguments[i].prototype);
+ inh.xynt_sup_cl.push(arguments[i]);
+ }
+
+ multi(inh, sub, true);
+
+
+ inh.callSuper = function(fnc){
+ var len = this.xynt_sup_cl.length;
+ for ( var i=0 ; i<len ; i++) {
+ var super = this.xynt_sup_cl[i];
+ if( (fnc in super.prototype) && (typeof super.prototype[fnc] == "function") ){
+ return super.prototype[fnc].apply(this,[].splice.call(arguments,1));
+ }
+ }
+ return null;
+ }
+
+ /*
+ inh.superrr = function(cl, method) {
+ console.log("xyx "+cl);
+ // console.log("xx"+arguments[0]);
+ // return this.xynt_sup_cl[cl].method.apply(this,arguments.slice(2));
+ }
+ */
+ sub.prototype = inh;
+
+ console.log("EXT FINISH");
+}
+
+function ExtendsInst(sub)
+{
+ var proto, cl, args;
+
+ console.log("INIZIO EXT INST");
+
+ var multi = function(sub, super, is_last)
+ {
+ var proto = super.prototype;
+
+ var single = function(sub, fun) {
+ var cur_fun = fun;
+
+ sub[cur_fun] = function(){
+ // console.log("INFU PR: " + proto[f] + " FUNC: "+f+" THIS: " + this);
+ console.log("SIMPLE LOG INST: "+cur_fun);
+ console.log(proto[cur_fun]);
+ console.log(sub);
+ console.log(arguments);
+ return proto[cur_fun].apply(this, arguments);
+ }
+ };
+
+ if (typeof(sub.xynt_sup) == 'undefined')
+ sub.xynt_sup = new Array();
+ if (typeof(sub.xynt_sup_cl) == 'undefined')
+ sub.xynt_sup_cl = new Array();
+
+ for (var f in proto) {
+ /* NOTE: this allow potentially TO BREAK by the extending class
+ if we disable it we don't have a reason to keep the callSuper function,
+ I need to meditate on it */
+ if (f == "xynt_sup" || f == "xynt_sup_cl")
+ continue;
+
+ console.log("ExtensInst::multi: "+f+" type: "+typeof(sub[f]));
+ if (typeof(sub[f]) != 'undefined') {
+ if (typeof(sub[f]) == typeof(proto[f]))
+ continue;
+ console.log("MULTI: false1");
+ return false;
+ }
+
+ console.log("LOOP: "+f);
+ if( f != "constructor" && typeof(proto[f]) == "function" && !is_last){
+ console.log("M_FU: "+proto[f]+" F: "+f);
+ single(sub, f);
+ }
+ else {
+ console.log("M_PR: "+proto.name+" A: "+f+" FUN: "+proto[f]);
+ sub[f] = proto[f];
+ }
+ }
+ return true;
+ };
+
+ console.log("POST FUNC");
+
+ for( var i=1; i < arguments.length ; i++){
+ console.log("POST FUNC IN LOOP");
+ cl = arguments[i];
+ if (i+1 < arguments.length && typeof(arguments[i+1]) != 'function') {
+ i++;
+ args = arguments[i];
+ }
+ if (multi(sub, cl, false) == false) {
+ console.log("POST FUNC FALSE 1");
+ return (false);
+ }
+
+ console.log("POST FUNC PRE APPLY");
+ cl.apply(sub, args);
+ console.log("POST FUNC POST APPLY");
+
+ sub.xynt_sup.push(cl.prototype);
+ sub.xynt_sup_cl.push(cl);
+ }
+
+ sub.callSuper = function(fnc){
+ var len = this.xynt_sup_cl.length;
+ for ( var i=0 ; i<len ; i++) {
+ var super = this.xynt_sup_cl[i];
+ if( (fnc in super.prototype) && (typeof super.prototype[fnc] == "function") ){
+ return super.prototype[fnc].apply(this,[].splice.call(arguments,1));
+ }
+ }
+ return null;
+ }
+
+ console.log("FINE EXT INST");
+ return true;
+}
+
+function show_class(cl) {
+ console.log("Attributes Class of "+cl);
+ for (f in cl.prototype) {
+ console.log(f+"-v");
+ console.log(cl.prototype[f]);
+ }
+ console.log("---");
+}
+
+function show_inst(inst) {
+ console.log("Attributes Instance of "+inst);
+ for (f in inst) {
+ console.log(f+"-v");
+ // console.log(inst[f]);
+ }
+ console.log("---");
+}
+