Examples of touserdata()


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

      "} )\n";
    Varargs chunk = _G.get("loadstring").call(LuaValue.valueOf(script));
    if ( ! chunk.arg1().toboolean() )
      fail( chunk.arg(2).toString() );
    LuaValue result = chunk.arg1().call();
    Object u = result.touserdata();
    VarArgsInterface v = (VarArgsInterface) u;
    assertEquals( "foo", v.varargsMethod("foo") );
    assertEquals( "foo-bar", v.varargsMethod("foo", "bar") );
    assertEquals( "foo-bar-etc", v.varargsMethod("foo", "bar", "etc") );
    assertEquals( "foo-0-nil-nil", v.arrayargsMethod("foo", new String[0]) );
View Full Code Here

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

    JavaClass c = JavaClass.forClass(B.class);
    assertEquals( JavaClass.class, c.getClass() );
    LuaValue constr = c.get("new");
    assertEquals( JavaConstructor.class, constr.getClass() );
    LuaValue v = constr.call(NUMS);
    Object b = v.touserdata();
    assertEquals( B.class, b.getClass() );
    assertEquals( 123, ((B)b).m_int_field );
    Object b0 = constr.call().touserdata();
    assertEquals( B.class, b0.getClass() );
    assertEquals( 0, ((B)b0).m_int_field );
View Full Code Here

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

    JavaClass f = JavaClass.forClass(B.class);
    LuaValue constr = f.get("new");
    assertEquals( JavaConstructor.class, constr.getClass() );
    try {
      LuaValue v = constr.call(LuaValue.userdataOf(new Object()));
      Object b = v.touserdata();
      // fail( "did not throw lua error as expected" );
      assertEquals( 0, ((B)b).m_int_field );
    } catch ( LuaError e ) {
    }
  }
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.