Examples of LuaString


Examples of org.luaj.vm2.LuaString

    assertEquals( LuaString.class, v.getClass() );
    assertEquals( "777", v.toString() );
  }

  public void testLuaStringToJavaString() {
    LuaString s = LuaValue.valueOf("777");
    Object o = CoerceLuaToJava.coerce(s, String.class);
    assertEquals( String.class, o.getClass() );
    assertEquals( "777", o );
  }
View Full Code Here

Examples of org.luaj.vm2.LuaString

  private String createLuaStringField(LuaString value) {
    String name = PREFIX_CONSTANT+constants.size();
    FieldGen fg = new FieldGen(Constants.ACC_STATIC | Constants.ACC_FINAL,
        TYPE_LUAVALUE, name, cp);
    cg.addField(fg.getField());
    LuaString ls = value.checkstring();
    if ( ls.isValidUtf8() ) {
      init.append(new PUSH(cp, value.tojstring()));
      init.append(factory.createInvoke(STR_LUASTRING, "valueOf",
          TYPE_LUASTRING, ARG_TYPES_STRING, Constants.INVOKESTATIC));
    } else {
      char[] c = new char[ls.m_length];
View Full Code Here

Examples of org.luaj.vm2.LuaString

    return funcstate.f;
  }

  // look up and keep at most one copy of each string
  public LuaString newTString(byte[] bytes, int offset, int len) {
    LuaString tmp = LuaString.valueOf(bytes, offset, len);
    LuaString v = (LuaString) strings.get(tmp);
    if ( v == null ) {
      // must copy bytes, since bytes could be from reusable buffer
      byte[] copy = new byte[len];
      System.arraycopy(bytes, offset, copy, 0, len);
      v = LuaString.valueOf(copy);
View Full Code Here

Examples of org.luaj.vm2.LuaString

  private Varargs ioread(File f, Varargs args) throws IOException {
    int i,n=args.narg();
    LuaValue[] v = new LuaValue[n];
    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;
View Full Code Here

Examples of org.luaj.vm2.LuaString

 
  public void testStringAndIntegerKeys() {
    LuaTable t = new_Table();
   
    for ( int i = 0; i < 10; ++i ) {
      LuaString str = LuaString.valueOf( String.valueOf( i ) );
      t.set( i, str );
      t.set( str, LuaInteger.valueOf( i ) );
    }
   
    assertTrue( t.getArrayLength() >= 9 ); // 1, 2, ..., 9
View Full Code Here

Examples of org.luaj.vm2.LuaString

  public void testInsertBeginningOfList() {
    LuaTable t = new_Table();
    Vector v = new Vector();
   
    for ( int i = 1; i <= 32; ++i ) {
      LuaString test = LuaString.valueOf("Test Value! "+i);
      t.insert(1, test);
      v.insertElementAt(test, 0);           
      compareLists(t,v);
    }
  }
View Full Code Here

Examples of org.luaj.vm2.LuaString

  public void testInsertEndOfList() {
    LuaTable t = new_Table();
    Vector v = new Vector();
   
    for ( int i = 1; i <= 32; ++i ) {
      LuaString test = LuaString.valueOf("Test Value! "+i);
      t.insert(0, test);
      v.insertElementAt(test, v.size());           
      compareLists(t,v);
    }
  }
View Full Code Here

Examples of org.luaj.vm2.LuaString

  public void testInsertMiddleOfList() {
    LuaTable t = new_Table();
    Vector v = new Vector();
   
    for ( int i = 1; i <= 32; ++i ) {
      LuaString test = LuaString.valueOf("Test Value! "+i);
      int m = i / 2;
      t.insert(m+1, test);
      v.insertElementAt(test, m);
      compareLists(t,v);
    }
View Full Code Here

Examples of org.luaj.vm2.LuaString

    }
  }
 
  private static final void prefillLists(LuaTable t,Vector v) {
    for ( int i = 1; i <= 32; ++i ) {
      LuaString test = LuaString.valueOf("Test Value! "+i);
      t.insert(0, test);
      v.insertElementAt(test, v.size());
    }
  }
View Full Code Here

Examples of org.luaj.vm2.LuaString

        } else if (isdigit(current)) {
          read_numeral(seminfo);
          return TK_NUMBER;
        } else if (isalpha(current) || current == '_') {
          /* identifier or reserved word */
          LuaString ts;
          do {
            save_and_next();
          } while (isalnum(current) || current == '_');
          ts = newstring(buff, 0, nbuff);
          if ( RESERVED.containsKey(ts) )
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.