Package org.luaj.vm2

Examples of org.luaj.vm2.LuaString


import java.io.IOException;

public class ModuleExecutor {
    public String run(IWikiModel model, String module, String method, Frame frame) throws IOException {
        final Globals globals = getGlobals();
        MwCommon common = new MwCommon(model, globals);
        return common.execute(module, method, frame);
    }
View Full Code Here


        MwCommon common = new MwCommon(model, globals);
        return common.execute(module, method, frame);
    }

    private Globals getGlobals() {
        final Globals globals = JsePlatform.standardGlobals();
//        LuaJC.install(globals);
        return globals;
    }
View Full Code Here

                    defaultAnimationName = animationName; // set first animation as the default one
                }
            }
            catch (SpriteException ex) {
                // Error in the input file.
                throw new LuaError(ex);
            }
            catch (Exception ex) {
                // Error in the editor.
                ex.printStackTrace();
                throw new LuaError(ex);
            }

            return LuaValue.NIL;
        }
View Full Code Here

            LuaC.install();
            LuaTable environment = LuaValue.tableOf();

            environment.set("animation", new AnimationFunction());

            LuaFunction code = LoadState.load(new FileInputStream(spriteFile),
                spriteFile.getName(), environment);
            code.call();
        }
        catch (IOException ex) {
            throw new SpriteException(ex.getMessage());
        }
        catch (LuaError ex) {
View Full Code Here

                    if (!param.get("raw").isnil()) {
                        actualParam = param.get("raw").checkjstring();
                    } else if (!param.get("num").isnil()) {
                        if (param.get("num").isnumber()) {
                            LuaNumber number = param.get("num").checknumber();
                            NumberFormat nf = NumberFormat.getInstance(Locale.forLanguageTag(lang));
                            actualParam = nf.format(number.todouble());
                        } else {
                            actualParam = param.get("num").tojstring();
                        }
                    } else {
                        actualParam = "unknown";
View Full Code Here

    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

  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

    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

  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

 
  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

TOP

Related Classes of org.luaj.vm2.LuaString

Copyright © 2018 www.massapicom. 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.