Package org.luaj.vm2

Examples of org.luaj.vm2.LuaValue


    switch ( opcode ) {
      case INIT: {
        return init();
      }
      case CREATE: {
        final LuaValue func = args.checkfunction(1);
        return new LuaThread(func, LuaThread.getGlobals() );
      }
      case RESUME: {
        final LuaThread t = args.checkthread(1);
        return t.resume( args.subargs(2) );
      }
      case RUNNING: {
        final LuaThread r = LuaThread.getRunning();
        return LuaThread.isMainThread(r)? NIL: r;
      }
      case STATUS: {
        return valueOf( args.checkthread(1).getStatus() );
      }
      case YIELD: {
        final LuaThread r = LuaThread.getRunning();
        if ( LuaThread.isMainThread( r ) )
          error("main thread can't yield");
        return r.yield( args );
      }
      case WRAP: {
        final LuaValue func = args.checkfunction(1);
        final LuaThread thread = new LuaThread(func, func.getfenv());
        CoroutineLib cl = new CoroutineLib();
        cl.setfenv(thread);
        cl.name = "wrapped";
        cl.opcode = WRAPPED;
        return cl;
View Full Code Here


  public List<String> getCommands() {
    List<String> cmds = Lists.newArrayList();
    if (!lv.isNil(LuaFields.COMMANDS)) {
      Iterator<LuaPair> pairsIter = lv.getTable(LuaFields.COMMANDS).arrayIterator();
      while (pairsIter.hasNext()) {
        LuaValue c = pairsIter.next().value;
        if (c.isstring()) {
          cmds.add(c.tojstring());
        } else if (c.istable()) {
          cmds.add(toCommand(new LuaWrapper(c.checktable())));
        }
      }
    } else if (!lv.isNil(LuaFields.COMMAND)) {
      if (lv.isTable(LuaFields.COMMAND)) {
        cmds.add(toCommand(lv.getTable(LuaFields.COMMAND)));
View Full Code Here

      readBytes(nameSize);
      String name = Buffer.utf8ToString(dataBuffer, 0, nameSize);
 
      int particleBytesSize = (int) (opSize - (4 + nameSize));
      readBytes(particleBytesSize);
      LuaValue aggregateValue = instance.getValue(particleType, dataBuffer, 0, particleBytesSize);
           
      if (! name.equals("SUCCESS")) {
        throw new AerospikeException("Query aggregate expected bin name SUCCESS.  Received " + name);
      }
     
View Full Code Here

    public Varargs invoke(Varargs args) {
      LuaList list = new LuaList(instance, new ArrayList<LuaValue>());
     
      if (args.istable(2)) {
        LuaTable table = args.checktable(2);
        LuaValue k = LuaValue.NIL;
       
        while (true) {
           Varargs n = table.next(k);
          
           if ((k = n.arg1()).isnil())
             break;

           LuaValue v = n.arg(2);
           list.append(v);
         }
      }       
      return LuaValue.varargsOf(new LuaValue[] {list});
    }
View Full Code Here

    public Varargs invoke(Varargs args) {
      LuaMap map = new LuaMap(instance, new HashMap<LuaValue,LuaValue>());
     
      if (args.istable(2)) {
        LuaTable table = args.checktable(2);
        LuaValue k = LuaValue.NIL;
       
        while (true) {
           Varargs n = table.next(k);
          
           if ((k = n.arg1()).isnil())
             break;

           LuaValue v = n.arg(2);
           map.put(k, v);
         }
      }       
      return LuaValue.varargsOf(new LuaValue[] {map});
    }
View Full Code Here

  }
 
  public static LuaTable onCCWrappedILuaObject(final LuaTable table, final ILuaObject object) {
    if(object instanceof CCCommandWrapper) {
      LuaTable lpTable = new LPLuaTable((CCCommandWrapper)object);
      LuaValue k = LuaValue.NIL;
      while(true) {
        Varargs n = table.next(k);
        if((k = n.arg1()).isnil()) break;
        LuaValue v = n.arg(2);
        lpTable.set(k, v);
      }
      ((CCCommandWrapper)object).table = lpTable;
      return lpTable;
    }
View Full Code Here

    public Tile(LuaTable table) {
        this.symbol = table.get("symbol").toString().charAt(0);
        this.colour = table.get("colour").checkint();

        LuaValue collid = table.get("collidable");
        if (collid.isboolean()) {
            this.collidable = table.get("collidable").checkboolean();
        }
        if (collid.isfunction()) {
            this.collideFunc = collid.checkfunction();
        }
    }
View Full Code Here

        UntrustedLua.showComputerPane(playerInventory.contains("computer"));

        addTilePropertyEvent("onTileCollision", "exit", new Runnable() {
            @Override
            public void run() {
                LuaValue exitRet = callScriptFunc(LuaMain.functions.EXIT);
                if (exitRet.isboolean() && exitRet.toboolean()) {
                    prevPlayerInventory = playerInventory.toArray(new String[0]);
                    levelIndex++;
                    loadLevel();
                }
            }
View Full Code Here

                // Traverse the directions table.
                LuaValue key = LuaValue.NIL;
                while (true) {

                    Varargs keyValue = directionsTable.next(key);
                    key = keyValue.arg1();
                    if (key.isnil()) {
                        break;
                    }
                    LuaValue directionTable = keyValue.arg(2);

                    int x = directionTable.get("x").checkint();
                    int y = directionTable.get("y").checkint();
                    int frameWidth = directionTable.get("frame_width").checkint();
                    int frameHeight = directionTable.get("frame_height").checkint();
View Full Code Here

        final int testCount        = tests.get("count").toint();
        final LuaValue provideFunc = tests.get("provide");
        final LuaValue runFunc     = tests.get("run");

        for (int i=1; i<testCount+1; i++) {
            final Varargs provideValue = provideFunc.invoke(valueOf(i));
            final LuaValue name = provideValue.arg(2);
            final String expected = provideValue.arg(3).checkjstring();

            Description testDescription = Description.createTestDescription(getClass(), name.toString());

            if (isIgnored(testDescription)) {
                notifier.fireTestIgnored(testDescription);
View Full Code Here

TOP

Related Classes of org.luaj.vm2.LuaValue

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.