jakarta-bsf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fabrício Matheus Gonçalves <fmath...@bigbross.com>
Subject JavaScriptEngine.declareBean() patch
Date Tue, 28 Jan 2003 22:00:21 GMT

Hi all,

That is the code:

Index: bsf/src/org/apache/bsf/engines/javascript/JavaScriptEngine.java
===================================================================
RCS file:
/home/cvspublic/jakarta-bsf/src/bsf-2.3/bsf/src/org/apache/bsf/engines/javascript/JavaScriptEngine.java,v
retrieving revision 1.2
diff -u -r1.2 JavaScriptEngine.java
--- bsf/src/org/apache/bsf/engines/javascript/JavaScriptEngine.java     7
Nov 2002 01:49:12 -0000       1.2
+++ bsf/src/org/apache/bsf/engines/javascript/JavaScriptEngine.java     28
Jan 2003 21:54:52 -0000
@@ -193,9 +193,15 @@
     }

     public void declareBean(BSFDeclaredBean bean) throws BSFException {
-        // Must wrap non-scriptable objects before presenting to Rhino
-        Scriptable wrapped = Context.toObject(bean.bean, global);
-        global.put(bean.name, global, wrapped);
+       if ((bean.bean instanceof Number) ||
+           (bean.bean instanceof String) ||
+           (bean.bean instanceof Boolean)) {
+           global.put(bean.name, global, bean.bean);
+       } else {
+           // Must wrap non-scriptable objects before presenting to Rhino
+           Scriptable wrapped = Context.toObject(bean.bean, global);
+           global.put(bean.name, global, wrapped);
+       }
     }

     /**



Mime
View raw message