Package org.luaj.vm2

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


 
  public void testJavaIntToLuaInt() {
    Integer i = Integer.valueOf(777);
    LuaValue v = CoerceJavaToLua.coerce(i);
    assertEquals( LuaInteger.class, v.getClass() );
    assertEquals( 777, v.toint() );
  }

  public void testLuaIntToJavaInt() {
    LuaInteger i = LuaInteger.valueOf(777);
    Object o = CoerceLuaToJava.coerce(i, int.class);
View Full Code Here


    assertEquals( 20, keys.length );
    for ( int i = 0; i < keys.length; ++i ) {
      LuaValue k = keys[i];
     
      if ( k instanceof LuaInteger ) {
        final int ik = k.toint();
        assertTrue( ik >= 0 && ik < 10 );
        final int mask = 1 << ik;
        assertTrue( ( intKeys & mask ) == 0 );
        intKeys |= mask;
      } else if ( k instanceof LuaString ) {
View Full Code Here

          break;
        case NUMBER_FORMAT_INTS_ONLY:
          if ( ! ALLOW_INTEGER_CASTING && ! o.isint() )
            throw new java.lang.IllegalArgumentException("not an integer: "+o);
          writer.write(LuaValue.TNUMBER);
          dumpInt(o.toint());
          break;
        case NUMBER_FORMAT_NUM_PATCH_INT32:
          if ( o.isint() ) {
            writer.write(LuaValue.TINT);
            dumpInt(o.toint());
View Full Code Here

          dumpInt(o.toint());
          break;
        case NUMBER_FORMAT_NUM_PATCH_INT32:
          if ( o.isint() ) {
            writer.write(LuaValue.TINT);
            dumpInt(o.toint());
          } else {
            writer.write(LuaValue.TNUMBER);
            dumpDouble(o.todouble());
          }
          break;
View Full Code Here

    LuaValue ai,vi;
    LuaString fmt;
    for ( i=0; i<n; ) {
      item: switch ( (ai = args.arg(i+1)).type() ) {
        case LuaValue.TNUMBER:
          vi = freadbytes(f,ai.toint());
          break item;
        case LuaValue.TSTRING:
          fmt = ai.checkstring();
          if ( fmt.m_length == 2 && fmt.m_bytes[fmt.m_offset] == '*' ) {
            switch ( fmt.m_bytes[fmt.m_offset+1] ) {
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.