Revision: 4148
          http://vexi.svn.sourceforge.net/vexi/?rev=4148&view=rev
Author:   mkpg2
Date:     2011-05-20 23:41:10 +0000 (Fri, 20 May 2011)

Log Message:
-----------
Fix. Support traps on functions as well as adding/removing properties.

Modified Paths:
--------------
    trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSFunction.java
    
trunk/org.vexi-library.js/src/test/java/test/js/exec/general/function_props.js

Modified: trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSFunction.java
===================================================================
--- trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSFunction.java 
2011-05-20 03:00:36 UTC (rev 4147)
+++ trunk/org.vexi-library.js/src/main/java/org/ibex/js/JSFunction.java 
2011-05-20 23:41:10 UTC (rev 4148)
@@ -24,6 +24,12 @@
        public int callType() { return CALLTYPE_APPLY; }
     }
     
+    private JS.Obj useObj(){ 
+       if(object==null) 
+               object = new JS.Obj();
+       return object;
+    }
+    
     public JS get(JS key) throws JSExn {
        if("apply".equals(JSU.toString(key)))
                //return METHOD;
@@ -32,12 +38,13 @@
        return object.get(key);
     }
     
-    public void put(JS key, JS val) throws JSExn {
-        if(object==null) {
-            object = new JS.Obj();
-        }
-        object.put(key, val);
+    public void put(JS key, JS val) throws JSExn { useObj().put(key, val); }
+    public void addTrap(JS key, JS function) throws JSExn { 
useObj().addTrap(key, function); }
+    public void delTrap(JS key, JS function) throws JSExn {
+       if(object==null) return;
+       object.delTrap(key, function);
     }
+    public Trap getTrap(JS key) { return useObj().getTrap(key); }
     
     public JS apply(JS this_, JS[] args) throws JSExn{
        // UNIDEAL .. we are prevented from yielding after apply is called

Modified: 
trunk/org.vexi-library.js/src/test/java/test/js/exec/general/function_props.js
===================================================================
--- 
trunk/org.vexi-library.js/src/test/java/test/js/exec/general/function_props.js  
    2011-05-20 03:00:36 UTC (rev 4147)
+++ 
trunk/org.vexi-library.js/src/test/java/test/js/exec/general/function_props.js  
    2011-05-20 23:41:10 UTC (rev 4148)
@@ -4,6 +4,10 @@
     return callee.prop;
 };
 f.prop = 1;
+f.trap ++= function(){
+       return 2;
+}
 
 assert(f.prop==1);
+assert(f.trap==2);
 assert(f()==1);
\ No newline at end of file


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

------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to