Revision: 3157
          http://vexi.svn.sourceforge.net/vexi/?rev=3157&view=rev
Author:   mkpg2
Date:     2008-10-30 02:28:09 +0000 (Thu, 30 Oct 2008)

Log Message:
-----------
Test & Fix. catch/finally ignored if cascading to special properties, e.g. 
Children.

Modified Paths:
--------------
    trunk/core/org.ibex.js/src/org/ibex/js/JS.jpp
    trunk/core/org.ibex.js/src/org/ibex/js/Thread.java
    trunk/core/org.ibex.js/src_dev/org/ibex/js/JSDynProxy.java
    
trunk/core/org.ibex.js/src_junit/test/js/exec/traps/pause_on_put/TestPauseOnPut.java
    trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp
    trunk/core/org.vexi.core/src/org/vexi/graphics/Font.java
    
trunk/core/org.vexi.core/src_junit/test/core/box/childrentrap/TestChildrenTrap.java

Added Paths:
-----------
    trunk/core/org.vexi.core/src_junit/test/core/box/childrentrap/exnInCascade.t

Modified: trunk/core/org.ibex.js/src/org/ibex/js/JS.jpp
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/JS.jpp       2008-10-30 02:02:11 UTC 
(rev 3156)
+++ trunk/core/org.ibex.js/src/org/ibex/js/JS.jpp       2008-10-30 02:28:09 UTC 
(rev 3157)
@@ -140,13 +140,13 @@
             if(t==null) return clonee.putAndTriggerTraps(key,val);
             
             if ((t = t.write()) != null){
-               boolean wasException = false;
+               JSExn wasException = null;
                try{
                        JS r = Scheduler.get().runBeforePut(t, val);
                                if(r!=Interpreter.CASCADE_PREVENTED)
                                        put(key, r);
                }catch(JSExn e){
-                       wasException = true;
+                       wasException = e;
                        throw e;
                }finally{
                    Scheduler.get().runAfterPut(wasException);
@@ -245,11 +245,11 @@
         public JS justTriggerTraps(JS key, JS val) throws JSExn {
             Trap t = (Trap)super.get(key, 1);
             if (t != null && (t = t.write()) != null){
-                boolean wasException = false;
+                JSExn wasException = null;
                 try{
                     val = Scheduler.get().runBeforePut(t, val);
                 }catch(JSExn e){
-                    wasException = true;
+                    wasException = e;
                     throw e;
                 }
                 finally{
@@ -262,13 +262,13 @@
         public JS putAndTriggerTraps(JS key, JS val) throws JSExn {
             Trap t = (Trap)super.get(key, 1);
             if (t != null && (t = t.write()) != null){
-               boolean wasException = false;
+               JSExn wasException = null;
                try{
                        JS r = Scheduler.get().runBeforePut(t, val);
                                if(r!=Interpreter.CASCADE_PREVENTED)
                                        put(key, r);
                }catch(JSExn e){
-                       wasException = true;
+                       wasException = e;
                        throw e;
                }
                /* REMARK can only have JSExns ... TODO remove later

Modified: trunk/core/org.ibex.js/src/org/ibex/js/Thread.java
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/Thread.java  2008-10-30 02:02:11 UTC 
(rev 3156)
+++ trunk/core/org.ibex.js/src/org/ibex/js/Thread.java  2008-10-30 02:28:09 UTC 
(rev 3157)
@@ -107,7 +107,7 @@
         }
 
         /** Execute write traps, part 2 */
-        public void runAfterPut(boolean wereExceptions) throws JSExn{
+        /*public void runAfterPut(boolean wereExceptions) throws JSExn{
             try{
                 if(!wereExceptions && current.currentInterpreter.f!=null)
                     current.currentInterpreter.run(null);
@@ -115,11 +115,19 @@
                 if(current.currentInterpreter.old==null) current.destroy();
                 else current.currentInterpreter = 
current.currentInterpreter.old;
             }
+        }*/
+
+        public void runAfterPut(JSExn e) throws JSExn{
+            try{
+                if(current.currentInterpreter.f!=null)
+                    current.currentInterpreter.run(e);
+            }finally{
+                if(current.currentInterpreter.old==null) current.destroy();
+                else current.currentInterpreter = 
current.currentInterpreter.old;
+            }
         }
-
         
         
-        
         /** Execute read traps, part 1 */
         public JS runBeforeGet(Trap t, JS trapname) throws JSExn{
             if( current==null)  setCurrent(new 
Thread(this,t.function(),false,null));

Modified: trunk/core/org.ibex.js/src_dev/org/ibex/js/JSDynProxy.java
===================================================================
--- trunk/core/org.ibex.js/src_dev/org/ibex/js/JSDynProxy.java  2008-10-30 
02:02:11 UTC (rev 3156)
+++ trunk/core/org.ibex.js/src_dev/org/ibex/js/JSDynProxy.java  2008-10-30 
02:28:09 UTC (rev 3157)
@@ -45,7 +45,7 @@
        
        public void put(JS key, JS value) throws JSExn {
        Trap rangeTrap = wtrap(SC_);
-        boolean rangeTrapException = false;
+        JSExn rangeTrapException = null;
         try {
             if (rangeTrap != null) {
                 value = Thread.Faction.getCurrent().runBeforePut(rangeTrap, 
value, key);
@@ -55,7 +55,7 @@
             }
             super.put(key,value);
         } catch (JSExn e) {
-            rangeTrapException = true;
+            rangeTrapException = e;
             throw e;
         } finally {
             if (rangeTrap != null) {

Modified: 
trunk/core/org.ibex.js/src_junit/test/js/exec/traps/pause_on_put/TestPauseOnPut.java
===================================================================
--- 
trunk/core/org.ibex.js/src_junit/test/js/exec/traps/pause_on_put/TestPauseOnPut.java
        2008-10-30 02:02:11 UTC (rev 3156)
+++ 
trunk/core/org.ibex.js/src_junit/test/js/exec/traps/pause_on_put/TestPauseOnPut.java
        2008-10-30 02:28:09 UTC (rev 3157)
@@ -26,29 +26,29 @@
            
            /** execute trap JS up until the put, giving extra control over the 
put
             *  it must ALWAYS be followed by a postPutTriggerTraps */
-           private final boolean prePutTriggerTrapsAndCatchExceptions(JS name, 
JS val) {
+           private final JSExn prePutTriggerTrapsAndCatchExceptions(JS name, 
JS val) {
                try {
                        Trap t = wtrap(name);
                        if(t!=null) RunJS.SCHEDULER.runBeforePut(t, val);
                } catch (JSExn e) {
                    Log.uWarn(TestPauseOnPut.class,"Caught JS Exception while 
putting to trap \""+name+"\"");
                    Log.uWarn(TestPauseOnPut.class,e);
-                   return true;
+                   return e;
                }/* REMARK can only have JSExns ... TODO remove later
                 catch (Exception e) {
                    Log.warn(this,"Caught Exception while putting to trap 
\""+name+"\"");
                    Log.warn(this,e);
                    return true;
                }*/
-               return false;
+               return null;
                
            }
 
            /** execute trap JS after a put */
-           private final void postPutTriggerTrapsAndCatchExceptions(JS name, 
boolean b) {
+           private final void postPutTriggerTrapsAndCatchExceptions(JS name, 
JSExn wasException) {
                try {
                        Trap t = wtrap(name);
-                       if(t!=null) RunJS.SCHEDULER.runAfterPut(b);
+                       if(t!=null) RunJS.SCHEDULER.runAfterPut(wasException);
                } catch (JSExn e) {
                    Log.uWarn(TestPauseOnPut.class,"Caught JS Exception while 
putting to trap \""+name+"\"");
                    Log.uWarn(TestPauseOnPut.class,e);
@@ -61,9 +61,9 @@
            ///
            // Testing pre and post putting
            public void putAndTriggerTrapsIgnoreCascade(JS name, JS val) throws 
JSExn{
-               boolean b = prePutTriggerTrapsAndCatchExceptions(name, val);
+               JSExn e = prePutTriggerTrapsAndCatchExceptions(name, val);
                put(name, val);
-               postPutTriggerTrapsAndCatchExceptions(name, b);
+               postPutTriggerTrapsAndCatchExceptions(name, e);
            }
 
            public void put(JS key, JS val) throws JSExn {

Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp
===================================================================
--- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp  2008-10-30 02:02:11 UTC 
(rev 3156)
+++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp  2008-10-30 02:28:09 UTC 
(rev 3157)
@@ -69,9 +69,9 @@
     //#define PUT_BOX_FIELD(NAME,VAL,CODE,FLAG)    \
     //  if (test(FLAG)) {\
     //      Trap _t_ = wtrap(NAME);\
-    //      boolean _b_ = prePutTriggerTrapsAndCatchExceptions(_t_, NAME, 
VAL);\
+    //      JSExn _e_ = prePutTriggerTrapsAndCatchExceptions(_t_, NAME, VAL);\
     //      CODE;\
-    //      postPutTriggerTrapsAndCatchExceptions(_t_, NAME, _b_);\
+    //      postPutTriggerTrapsAndCatchExceptions(_t_, NAME, _e_);\
     //  } else {CODE;}
     
     // check and set functions
@@ -815,22 +815,22 @@
     
     /** execute trap JS up until the put, giving extra control over the put
      *  it must ALWAYS be followed by a postPutTriggerTraps */
-    private final boolean prePutTriggerTrapsAndCatchExceptions(Trap t, JS 
name, JS val) {
+    private final JSExn prePutTriggerTrapsAndCatchExceptions(Trap t, JS name, 
JS val) {
         try {
             if (t != null) Main.SCHEDULER.runBeforePut(t, val);
         } catch (JSExn e) {
             Log.uWarn(Box.class,"Caught JS Exception while putting to trap 
\""+name+"\"");
             Log.uWarn(Box.class,e);
-            return true;
+            return e;
         }
-        return false;
+        return null;
         
     }
 
     /** execute trap JS after a put */
-    private final void postPutTriggerTrapsAndCatchExceptions(Trap t, JS name, 
boolean b) {
+    private final void postPutTriggerTrapsAndCatchExceptions(Trap t, JS name, 
JSExn trapException) {
         try {
-            if (t != null) Main.SCHEDULER.runAfterPut(b);
+            if (t != null) Main.SCHEDULER.runAfterPut(trapException);
         } catch (JSExn e) {
             Log.uWarn(Box.class,"Caught JS Exception while putting to trap 
\""+name+"\"");
             Log.uWarn(Box.class,e);
@@ -1576,7 +1576,7 @@
     // exist!
     private void put(int i, JS value, boolean fireTrapsOnRemove, boolean 
viaRedirect) throws JSExn{
        Trap rangeTrap = wtrap(SC_Children);
-        boolean rangeTrapException = false;
+        JSExn rangeTrapException = null;
         try {
             if (rangeTrap != null) {
                 value = Main.SCHEDULER.runBeforePut(rangeTrap, value, 
JSU.N(i));
@@ -1629,7 +1629,7 @@
             }
 
         } catch (JSExn e) {
-            rangeTrapException = true;
+            rangeTrapException = e;
             throw e;
         } finally {
             if (rangeTrap != null) {

Modified: trunk/core/org.vexi.core/src/org/vexi/graphics/Font.java
===================================================================
--- trunk/core/org.vexi.core/src/org/vexi/graphics/Font.java    2008-10-30 
02:02:11 UTC (rev 3156)
+++ trunk/core/org.vexi.core/src/org/vexi/graphics/Font.java    2008-10-30 
02:28:09 UTC (rev 3157)
@@ -189,7 +189,7 @@
         try {
             Log.debug(Font.class, "rasterizing glyph " + glyph.c + " of font " 
+ glyph.font);
             if (Font.loadedStream != glyph.font.stream) {
-               Log.info(Font.class, "loading font stream " + 
glyph.font.stream);
+               Log.warn(Font.class, "loading font stream " + 
glyph.font.stream);
                loadFontByteStream(glyph.font.stream);
             }
             

Modified: 
trunk/core/org.vexi.core/src_junit/test/core/box/childrentrap/TestChildrenTrap.java
===================================================================
--- 
trunk/core/org.vexi.core/src_junit/test/core/box/childrentrap/TestChildrenTrap.java
 2008-10-30 02:02:11 UTC (rev 3156)
+++ 
trunk/core/org.vexi.core/src_junit/test/core/box/childrentrap/TestChildrenTrap.java
 2008-10-30 02:28:09 UTC (rev 3157)
@@ -26,7 +26,7 @@
     public static void main(String[] args) throws Throwable {
 
        CoreTestSuite cts = new TestChildrenTrap();
-       TestCase t = cts.createTestCase(cts.getResourceDirs(), 
"readNoCascade.t");
+       TestCase t = cts.createTestCase(cts.getResourceDirs(), 
"exnInCascade.t");
        t.runBare();
        }
 }

Added: 
trunk/core/org.vexi.core/src_junit/test/core/box/childrentrap/exnInCascade.t
===================================================================
--- 
trunk/core/org.vexi.core/src_junit/test/core/box/childrentrap/exnInCascade.t    
                            (rev 0)
+++ 
trunk/core/org.vexi.core/src_junit/test/core/box/childrentrap/exnInCascade.t    
    2008-10-30 02:28:09 UTC (rev 3157)
@@ -0,0 +1,34 @@
+<vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib">
+    
+    <ui:box>
+        var s = {};
+        thisbox.surface ++= function() { return s; }
+        
+        var finallyInChildren = false;
+        
+        thisbox.Children ++= function(v){
+               try{
+                       cascade = v;
+            }finally{
+               vexi.trace("here");
+               finallyInChildren = true;
+            }
+        };
+        
+        var child = vexi.box;
+        child.surface ++= function(v){
+            cascade = v;
+               throw "xxx";
+        };
+        
+        var exceptionHappened = true;
+        try{
+               thisbox[0] = child;
+               exceptionHappened = false;
+        }catch(e){}
+        
+        assert(exceptionHappened);
+        assert(finallyInChildren);
+        
+    </ui:box>
+</vexi>


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to