ExtendsInst function added to extends a previous object
authorMatteo Nastasi <matteo.nastasi@lucinilucini.com>
Thu, 24 Nov 2011 17:59:52 +0000 (18:59 +0100)
committerMatteo Nastasi <matteo.nastasi@lucinilucini.com>
Thu, 24 Nov 2011 17:59:52 +0000 (18:59 +0100)
xynt-base.js

index 157141b..a2cfd24 100644 (file)
@@ -44,6 +44,19 @@ function Extends(sub)
     }
 
     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);
@@ -76,8 +89,13 @@ function ExtendsInst(sub)
             if (f == "xynt_sup" || f == "xynt_sup_cl")
                 continue;
             
-            if (typeof(sub[f]) != 'undefined')
+            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){
@@ -117,6 +135,17 @@ function ExtendsInst(sub)
         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;
 }
@@ -132,7 +161,7 @@ function show_class(cl) {
 function show_inst(inst) {
     console.log("Attributes Instance of "+inst);
     for (f in inst) {
-        console.log(f+": ["+inst[f]+"]");
+        console.log("["+f+"]: ["+inst[f]+"]");
     }
     console.log("---");
 }