Example #1
0
  /**
   * Caches a block of code, returning a handle that can be passed to runCachedBlock().
   *
   * @param id An identifier. If null, a unique identifier is generated
   * @param code The code
   * @param namespace If true, the namespace will be set
   * @return Description of the Return Value
   * @exception Exception instances are thrown when various BeanShell errors occur
   * @since jEdit 4.1pre1
   */
  public BshMethod cacheBlock(String id, String code, boolean namespace) throws Exception {
    String name = "__internal_" + id;

    // evaluate a method declaration
    if (namespace) {
      _eval(global, name + "(ns) {\nthis.callstack.set(0,ns);\n" + code + "\n}");
      return global.getMethod(name, new Class[] {NameSpace.class});
    } else {
      _eval(global, name + "() {\n" + code + "\n}");
      return global.getMethod(name, new Class[0]);
    }
  } // }}}
Example #2
0
 /**
  * Description of the Method
  *
  * @param namespace Description of the Parameter
  * @exception UtilEvalError Description of the Exception
  */
 private void resetDefaultVariables(NameSpace namespace)
       // throws UtilEvalError {
     {
   try {
     namespace.setVariable("reg", factory, false);
   } catch (UtilEvalError ex) {
     log.error(ex, ex);
   }
 } // }}}
Example #3
0
  /** Description of the Method */
  public void init() {

    global = new NameSpace(new BshClassManager(), "Embedded BeanShell interpreter");
    // global.importPackage("org.gjt.sp.util");
    global.importPackage("org.twdata.TW1606U.gui");
    global.importPackage("org.twdata.TW1606U.signal");
    global.importPackage("org.twdata.TW1606U.action");
    global.importPackage("org.twdata.TW1606U.tw");
    global.importPackage("org.twdata.TW1606U.tw.data");
    global.importPackage("org.twdata.TW1606U.data");
    global.importPackage("org.twdata.TW1606U.tw.model");
    global.importPackage("org.twdata.TW1606U.tw.signal");
    global.importPackage("org.werx.framework.bus");
    interpForMethods = createInterpreter(global);
  } // }}}