Package org.luaj.vm2

Examples of org.luaj.vm2.LuaValue.invoke()


      return;
    }
   
    Prototype prototype = LuaCache.loadPackage(packageName, system);
    LuaClosure function = new LuaClosure(prototype, globals);
    function.invoke();
   
    packageLib.loaded.set(packageName, globals);
  }

  public void call(String functionName, LuaValue[] args) {
View Full Code Here


      return;
    }
   
    Prototype prototype = LuaCache.loadPackage(packageName, system);
    LuaClosure function = new LuaClosure(prototype, globals);
    function.invoke();
   
    loadedTable.set(packageName, LuaValue.TRUE);
  }

  public void call(String functionName, LuaValue[] args) {
View Full Code Here

      return;
    }
   
    Prototype prototype = LuaCache.loadPackage(packageName, system);
    LuaClosure function = new LuaClosure(prototype, globals);
    function.invoke();
   
    loadedTable.set(packageName, LuaValue.TRUE);
  }

  public void call(String functionName, LuaValue[] args) {
View Full Code Here

      return;
    }
   
    Prototype prototype = LuaCache.loadPackage(packageName, system);
    LuaClosure function = new LuaClosure(prototype, globals);
    function.invoke();
   
    loadedTable.set(packageName, LuaValue.TRUE);
  }

  public void call(String functionName, LuaValue[] args) {
View Full Code Here

      return;
    }
   
    Prototype prototype = LuaCache.loadPackage(packageName, system);
    LuaClosure function = new LuaClosure(prototype, globals);
    function.invoke();
   
    loadedTable.set(packageName, LuaValue.TRUE);
  }

  public void call(String functionName, LuaValue[] args) {
View Full Code Here

    public Object eval(ScriptContext context) throws ScriptException {
          Bindings b = context.getBindings(ScriptContext.ENGINE_SCOPE);
          LuaFunction f = newFunctionInstance();
          ClientBindings cb = new ClientBindings(b);
          f.setfenv(cb.env);
      Varargs result = f.invoke(LuaValue.NONE);
      cb.copyGlobalsToBindings();
      return result;
    }
  }
 
View Full Code Here

  public void testLuaErrorCause() {
    String script = "luajava.bindClass( \""+SomeClass.class.getName()+"\"):someMethod()";
    LuaValue chunk = _G.get("loadstring").call(LuaValue.valueOf(script));
    try {
      chunk.invoke(LuaValue.NONE);
      fail( "call should not have succeeded" );
    } catch ( LuaError lee ) {
      Throwable c = lee.getCause();
      assertEquals( SomeException.class, c.getClass() );
    }
View Full Code Here

      // call with arguments
      LuaValue[] vargs = new LuaValue[args.length];
      for ( int i=0; i<args.length; i++ )
        vargs[i] = LuaValue.valueOf(args[i]);
      Varargs cargs = LuaValue.varargsOf(vargs);
      Varargs v = chunk.invoke(cargs);
     
      // print the result
      for ( int i=1; i<=v.narg(); i++ )
        System.out.println("result["+i+"]: "+v.arg(i));
    } catch ( Throwable e ) {
View Full Code Here

    assertEquals( "uniq()",                   uniq.call(SOMEB).tojstring() );
    assertEquals( "uniqs(string:abc)",        uniqs.call(SOMEB,ABC).tojstring() );
    assertEquals( "uniqi(int:1)",             uniqi.call(SOMEB,ONE).tojstring() );
    assertEquals( "uniqsi(string:abc,int:1)", uniqsi.call(SOMEB,ABC,ONE).tojstring() );
    assertEquals( "uniqis(int:1,string:abc)", uniqis.call(SOMEB,ONE,ABC).tojstring() );
    assertEquals( "uniqis(int:1,string:abc)", uniqis.invoke(LuaValue.varargsOf(new LuaValue[] {SOMEB,ONE,ABC,ONE})).arg1().tojstring() );
  }
  public void testOverloadedMethodAttributeCoercible() {
    B b = new B();
    JavaInstance ib = new JavaInstance(b);
    LuaValue p = ib.get("pick");
View Full Code Here

    assertEquals( "pick()",           p.call(SOMEB).tojstring() );
    assertEquals( "pick(string:abc)", p.call(SOMEB,ABC).tojstring() );
    assertEquals( "pick(int:1)",      p.call(SOMEB,ONE).tojstring() );
    assertEquals( "pick(string:abc,int:1)", p.call(SOMEB,ABC,ONE).tojstring() );
    assertEquals( "pick(int:1,string:abc)", p.call(SOMEB,ONE,ABC).tojstring() );
    assertEquals( "pick(int:1,string:abc)", p.invoke(LuaValue.varargsOf(new LuaValue[] {SOMEB,ONE,ABC,ONE})).arg1().tojstring() );
  }
  public void testUnboundOverloadedMethodAttributeCoercible() {
    B b = new B();
    JavaInstance ib = new JavaInstance(b);
    LuaValue p = ib.get("pick");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.