Package org.luaj.vm2

Examples of org.luaj.vm2.LuaClosure


        }
        return table;
    }

    private LuaTable luaDataForNamespace(INamespaceValue namespaceValue) {
        LuaTable ns = new LuaTable();
        ns.set("id", namespaceValue.getCode().code);
        ns.set("name", namespaceValue.getPrimaryText().replace('_', ' '));
        ns.set("canonicalName", namespaceValue.getCanonicalName().replace('_', ' '));
        ns.set("hasSubpages", LuaValue.valueOf(namespaceValue.hasSubpages()));
        ns.set("hasGenderDistinction", LuaValue.valueOf(namespaceValue.hasGenderDistinction()));
        ns.set("isCapitalized", LuaValue.valueOf(namespaceValue.isCapitalized()));
        ns.set("isContent", LuaValue.valueOf(namespaceValue.isContent()));
        ns.set("isIncludable", LuaValue.valueOf(namespaceValue.isIncludable()));
        ns.set("isMovable", LuaValue.valueOf(namespaceValue.isMovable()));
        ns.set("isSubject", LuaValue.valueOf(namespaceValue.isSubject()));
        ns.set("isTalk", LuaValue.valueOf(namespaceValue.isTalk()));
        ns.set("defaultContentModel", NIL);

        LuaValue[] aliases = new LuaValue[namespaceValue.getTexts().size()-1];
        for (int i=0; i<namespaceValue.getTexts().size()-1; i++) {
            aliases[i] = LuaValue.valueOf(namespaceValue.getTexts().get(i+1));
        }
        ns.set("aliases", LuaValue.listOf(aliases));

        if (namespaceValue.getCode().code >= INamespace.NamespaceCode.MAIN_NAMESPACE_KEY.code) {
            ns.set("subject",    namespaceValue.getContentspace().getCode().code);
            ns.set("talk",       namespaceValue.getTalkspace().getCode().code);
            Namespace.NamespaceValue associated = namespaceValue.getAssociatedspace();
            if (associated != null) {
                ns.set("associated", associated.getCode().code);
            } else {
                ns.set("associated", NIL);
            }
        } else {
            ns.set("subject", namespaceValue.getCode().code);
        }
        return ns;
    }
View Full Code Here


        return "mw.uri";
    }

    @Override
    public LuaTable getInterface() {
        LuaTable iface = new LuaTable();
        iface.set("anchorEncode", anchorEncode());
        iface.set("localUrl", localUrl());
        iface.set("fullUrl", fullUrl());
        iface.set("canonicalUrl", canonicalUrl());
        return iface;
    }
View Full Code Here

        };
    }

    @Override
    public LuaValue getSetupOptions() {
        LuaTable options = new LuaTable();
        return options;
    }
View Full Code Here

    private String formatQuery(LuaValue page, LuaValue query) {
        if (query.isstring()) {
            return wgScript + "?title="+page.checkstring()+"&"+query.checkjstring();
        } else if (query.istable()) {
            LuaTable params = query.checktable();

            String base = wgScript + "?title="+page.checkstring()+"&";
            for (LuaValue key : params.keys()) {
                base += (key.tojstring() + "=" + params.get(key).tojstring());
            }
            return base;
        } else {
            throw new AssertionError("unexpected type: "+query);
        }
View Full Code Here

    this.instance = instance;
    instance.load(new MetaLib(instance));
  }

  public LuaValue call(LuaValue env) {
    LuaTable meta = new LuaTable(0,2);
    meta.set("__call", new create(instance));
   
    LuaTable table = new LuaTable(0,10);
    table.setmetatable(meta);
    table.set("size", new len());
    table.set("set_size", new set_size());
   
    new getint(table, 0, "get_int16");
    new getint(table, 1, "get_int32");
    new getint(table, 2, "get_int64");

    new setint(table, 0, "set_int16");
    new setint(table, 1, "set_int32");
    new setint(table, 2, "set_int64");
   
    table.set("set_string", new set_string());
    table.set("set_bytes", new set_bytes());

    table.set("get_type", new get_type());
    table.set("set_type", new set_type());

    instance.registerPackage("bytes", table);
    return table;
  }
View Full Code Here

    public MetaLib(LuaInstance instance) {
      this.instance = instance;
    }

    public LuaValue call(LuaValue env) {
      LuaTable meta = new LuaTable(0, 5);
      meta.set("__len", new len());
      meta.set("__tostring", new tostring());
      meta.set("__index", new index());
      meta.set("__newindex", new newindex());
     
      instance.registerPackage("Bytes", meta);
      return meta;
    }
View Full Code Here

  public LuaAerospikeLib(LuaInstance instance) {
    this.instance = instance;
  }

  public LuaValue call(LuaValue env) {   
    LuaTable meta = new LuaTable();
    meta.set("__index", new index());
   
    LuaTable table = new LuaTable();   
    table.setmetatable(meta);
   
    instance.registerPackage("aerospike", table);   
    return table;
  }
View Full Code Here

  public LuaStreamLib(LuaInstance instance) {
    this.instance = instance;
  }
 
  public LuaValue call(LuaValue env) {
    LuaTable meta = new LuaTable(0,1);
    meta.set("__tostring", new tostring());
   
    LuaTable table = new LuaTable(0,10);
    table.setmetatable(meta);
    table.set("read", new read());
    table.set("readable", new readable());
    table.set("writeable", new writeable());
    table.set("write", new write());
   
    instance.registerPackage("stream", table);
    return table;
  }
View Full Code Here

   
    final static String LUADIR = "lua";
   
    public static boolean init () {
    String script = LUADIR + "\\sv_init.lua";
        LuaValue _G = JsePlatform.standardGlobals();
        try {
            _G.get("dofile").call(LuaValue.valueOf(script));
           
        } catch (org.luaj.vm2.LuaError ex) {
            Main.ui.commitln("Error: " + ex.getMessage());
            Main.ui.commitln(sutil.ADVICE.REINSTALL.s());
            return true;
View Full Code Here

                }

                Vector<SpriteAnimationDirection> directions = new Vector<SpriteAnimationDirection>();

                // 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();
                    int originX = directionTable.get("origin_x").optint(0);
                    int originY = directionTable.get("origin_y").optint(0);
                    int numFrames = directionTable.get("num_frames").optint(1);
                    int numColumns = directionTable.get("num_columns").optint(numFrames);

                    Rectangle firstFrameRectangle = new Rectangle(x, y, frameWidth, frameHeight);

                    try {
                      SpriteAnimationDirection direction =  new SpriteAnimationDirection(
View Full Code Here

TOP

Related Classes of org.luaj.vm2.LuaClosure

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.