當前位置: 首頁>>代碼示例>>Java>>正文


Java LuaValue.set方法代碼示例

本文整理匯總了Java中org.luaj.vm2.LuaValue.set方法的典型用法代碼示例。如果您正苦於以下問題:Java LuaValue.set方法的具體用法?Java LuaValue.set怎麽用?Java LuaValue.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.luaj.vm2.LuaValue的用法示例。


在下文中一共展示了LuaValue.set方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue modname, LuaValue env) {
	globals = env.checkglobals();
	
	// io lib functions
	LuaTable t = new LuaTable();
	bind(t, IoLibV.class, IO_NAMES );
	
	// create file methods table
	filemethods = new LuaTable();
	bind(filemethods, IoLibV.class, FILE_NAMES, FILE_CLOSE );

	// set up file metatable
	LuaTable mt = new LuaTable();
	bind(mt, IoLibV.class, new String[] { "__index" }, IO_INDEX );
	t.setmetatable( mt );
	
	// all functions link to library instance
	setLibInstance( t );
	setLibInstance( filemethods );
	setLibInstance( mt );
	
	// return the table
	env.set("io", t);
	env.get("package").get("loaded").set("io", t);
	return t;
}
 
開發者ID:hsllany,項目名稱:HtmlNative,代碼行數:27,代碼來源:IoLib.java

示例2: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue modname, LuaValue env) {
    globals = env.checkglobals();
    globals.set("require", new require());
    package_ = new LuaTable();
    package_.set(_LOADED, new LuaTable());
    package_.set(_PRELOAD, new LuaTable());
    package_.set(_PATH, LuaValue.valueOf(DEFAULT_LUA_PATH));
    package_.set(_LOADLIB, new loadlib());
    package_.set(_SEARCHPATH, new searchpath());
    LuaTable searchers = new LuaTable();
    searchers.set(1, preload_searcher = new preload_searcher());
    searchers.set(2, lua_searcher = new lua_searcher());
    searchers.set(3, java_searcher = new java_searcher());
    package_.set(_SEARCHERS, searchers);
    package_.get(_LOADED).set("package", package_);
    env.set("package", package_);
    globals.package_ = this;
    return env;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:20,代碼來源:PackageLib.java

示例3: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/** Perform one-time initialization on the library by creating a table
 * containing the library functions, adding that table to the supplied environment,
 * adding the table to package.loaded, and returning table as the return value.
 * <P>Specifically, adds all library functions that can be implemented directly
 * in JSE but not JME: acos, asin, atan, atan2, cosh, exp, log, pow, sinh, and tanh.
 * @param modname the module name supplied if this is loaded via 'require'.
 * @param env the environment to load into, which must be a Globals instance.
 */
public LuaValue call(LuaValue modname, LuaValue env) {
	super.call(modname, env);
	LuaValue math = env.get("math");
	math.set("acos", new acos());
	math.set("asin", new asin());
	math.set("atan", new atan());
	math.set("atan2", new atan2());
	math.set("cosh", new cosh());
	math.set("exp", new exp());
	math.set("log", new log());
	math.set("pow", new pow());
	math.set("sinh", new sinh());
	math.set("tanh", new tanh());
	return math;
}
 
開發者ID:hsllany,項目名稱:HtmlNative,代碼行數:24,代碼來源:JseMathLib.java

示例4: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/** Perform one-time initialization on the library by creating a table
 * containing the library functions, adding that table to the supplied environment,
 * adding the table to package.loaded, and returning table as the return value.
 * @param modname the module name supplied if this is loaded via 'require'.
 * @param env the environment to load into, which must be a Globals instance.
 */
public LuaValue call(LuaValue modname, LuaValue env) {
	globals = env.checkglobals();
	globals.debuglib = this;
	LuaTable debug = new LuaTable();
	debug.set("debug", new debug());
	debug.set("gethook", new gethook());
	debug.set("getinfo", new getinfo());
	debug.set("getlocal", new getlocal());
	debug.set("getmetatable", new getmetatable());
	debug.set("getregistry", new getregistry());
	debug.set("getupvalue", new getupvalue());
	debug.set("getuservalue", new getuservalue());
	debug.set("sethook", new sethook());
	debug.set("setlocal", new setlocal());
	debug.set("setmetatable", new setmetatable());
	debug.set("setupvalue", new setupvalue());
	debug.set("setuservalue", new setuservalue());
	debug.set("traceback", new traceback());
	debug.set("upvalueid", new upvalueid());
	debug.set("upvaluejoin", new upvaluejoin());
	env.set("debug", debug);
	env.get("package").get("loaded").set("debug", debug);
	return debug;
}
 
開發者ID:nekocode,項目名稱:Hubs,代碼行數:31,代碼來源:DebugLib.java

示例5: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
@Override
public final LuaValue call(LuaValue modname, LuaValue env) {
    LuaValue library = tableOf();

    // Load library table
    Map<String, LuaValue> table = new HashMap<>();
    load(table);
    table.forEach(library::set);

    env.set(key, library);
    return library;
}
 
開發者ID:ImpactDevelopment,項目名稱:ClientAPI,代碼行數:13,代碼來源:LuaLibrary.java

示例6: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue modname, LuaValue env) {
    globals = env.checkglobals();
    globals.debuglib = this;
    LuaTable debug = new LuaTable();
    debug.set("debug", new debug());
    debug.set("gethook", new gethook());
    debug.set("getinfo", new getinfo());
    debug.set("getlocal", new getlocal());
    debug.set("getmetatable", new getmetatable());
    debug.set("getregistry", new getregistry());
    debug.set("getupvalue", new getupvalue());
    debug.set("getuservalue", new getuservalue());
    debug.set("sethook", new sethook());
    debug.set("setlocal", new setlocal());
    debug.set("setmetatable", new setmetatable());
    debug.set("setupvalue", new setupvalue());
    debug.set("setuservalue", new setuservalue());
    debug.set("traceback", new traceback());
    debug.set("upvalueid", new upvalueid());
    debug.set("upvaluejoin", new upvaluejoin());
    debug.set("traceback_count", new tracebackCount());

    //extend for luaview
    new com.taobao.luaview.vm.extend.DebugLib(this, globals).extend(debug);

    env.set("debug", debug);
    env.get("package").get("loaded").set("debug", debug);
    return debug;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:30,代碼來源:DebugLib.java

示例7: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/** Perform one-time initialization on the library by creating a table
 * containing the library functions, adding that table to the supplied environment,
 * adding the table to package.loaded, and returning table as the return value.
 * @param modname the module name supplied if this is loaded via 'require'.
 * @param env the environment to load into, which must be a Globals instance.
 */
public LuaValue call(LuaValue modname, LuaValue env) {
	globals = env.checkglobals();
	LuaTable coroutine = new LuaTable();
	coroutine.set("create", new create());
	coroutine.set("resume", new resume());
	coroutine.set("running", new running());
	coroutine.set("status", new status());
	coroutine.set("yield", new yield());
	coroutine.set("wrap", new wrap());
	env.set("coroutine", coroutine);
	env.get("package").get("loaded").set("coroutine", coroutine);
	return coroutine;
}
 
開發者ID:hsllany,項目名稱:HtmlNative,代碼行數:20,代碼來源:CoroutineLib.java

示例8: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue modname, LuaValue env) {
	super.call(modname, env);
	LuaValue math = env.get("math");
	math.set("acos", new acos());
	math.set("asin", new asin());
	math.set("atan", new atan());
	math.set("atan2", new atan2());
	math.set("cosh", new cosh());
	math.set("exp", new exp());
	math.set("log", new log());
	math.set("pow", new pow());
	math.set("sinh", new sinh());
	math.set("tanh", new tanh());
	return math;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:16,代碼來源:JseMathLib.java

示例9: luaMain

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/** Simple wrapper for invoking a lua function with command line arguments.  
 * The supplied function is first given a new Globals object, 
 * then the program is run with arguments.
 */
public static void luaMain(LuaValue mainChunk, String[] args) {
	Globals g = standardGlobals();
	int n = args.length;
	LuaValue[] vargs = new LuaValue[args.length];
	for (int i = 0; i < n; ++i)
		vargs[i] = LuaValue.valueOf(args[i]);
	LuaValue arg = LuaValue.listOf(vargs);
	arg.set("n", n);
	g.set("arg", arg);
	mainChunk.initupvalue1(g);
	mainChunk.invoke(LuaValue.varargsOf(vargs));
}
 
開發者ID:nekocode,項目名稱:Hubs,代碼行數:17,代碼來源:JsePlatform.java

示例10: toLuaTable

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/**
 * Transforming a collection of strings to a LUA value table.
 * 
 * @param collection
 * 				Collection of strings.
 * @return
 * 				LUA value table.
 */
public static LuaValue toLuaTable(Collection<String> collection) {
	LuaValue table = LuaValue.tableOf();
	int i = 1;
	for (String s : collection) {
		table.set(i, LuaValue.valueOf(s));
		i++;
	}
	return table;
}
 
開發者ID:joakimkistowski,項目名稱:HTTP-Load-Generator,代碼行數:18,代碼來源:LuaHelpers.java

示例11: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/** Perform one-time initialization on the library by creating a table
 * containing the library functions, adding that table to the supplied environment,
 * adding the table to package.loaded, and returning table as the return value.
 * @param modname the module name supplied if this is loaded via 'require'.
 * @param env the environment to load into, typically a Globals instance.
 */
public LuaValue call(LuaValue modname, LuaValue env) {
	globals = env.checkglobals();
	LuaTable os = new LuaTable();
	for (int i = 0; i < NAMES.length; ++i)
		os.set(NAMES[i], new OsLibFunc(i, NAMES[i]));
	env.set("os", os);
	env.get("package").get("loaded").set("os", os);
	return os;
}
 
開發者ID:nekocode,項目名稱:Hubs,代碼行數:16,代碼來源:OsLib.java

示例12: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call( LuaValue arg ) {
	LuaString name = arg.checkstring();
	LuaValue loaded = package_.get(_LOADED);
	LuaValue result = loaded.get(name);
	if ( result.toboolean() ) {
		if ( result == _SENTINEL )
			error("loop or previous error loading module '"+name+"'");
		return result;
	}
	
	/* else must load it; iterate over available loaders */
	LuaTable tbl = package_.get(_SEARCHERS).checktable();
	StringBuffer sb = new StringBuffer();
	Varargs loader = null;
	for ( int i=1; true; i++ ) {
		LuaValue searcher = tbl.get(i);
		if ( searcher.isnil() ) {
			error( "module '"+name+"' not found: "+name+sb );				
	    }
					
	    /* call loader with module name as argument */
		loader = searcher.invoke(name);
		if ( loader.isfunction(1) )
			break;
		if ( loader.isstring(1) )
			sb.append( loader.tojstring(1) );
	}
	
	// load the module using the loader
	loaded.set(name, _SENTINEL);
	result = loader.arg1().call(name, loader.arg(2));
	if ( ! result.isnil() )
		loaded.set( name, result );
	else if ( (result = loaded.get(name)) == _SENTINEL ) 
		loaded.set( name, result = LuaValue.TRUE );
	return result;
}
 
開發者ID:nekocode,項目名稱:Hubs,代碼行數:38,代碼來源:PackageLib.java

示例13: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public LuaValue call(LuaValue modname, LuaValue env) {
	LuaTable t = new LuaTable();
	bind(t, Bit32LibV.class, new String[] {
		"band", "bnot", "bor", "btest", "bxor", "extract", "replace"
	});
	bind(t, Bit32Lib2.class, new String[] {
		"arshift", "lrotate", "lshift", "rrotate", "rshift"
	});
	env.set("bit32", t);
	env.get("package").get("loaded").set("bit32", t);
	return t;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:13,代碼來源:Bit32Lib.java

示例14: call

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
/** Perform one-time initialization on the library by creating a table
 * containing the library functions, adding that table to the supplied environment,
 * adding the table to package.loaded, and returning table as the return value.
 * @param modname the module name supplied if this is loaded via 'require'.
 * @param env the environment to load into, typically a Globals instance.
 */
public LuaValue call(LuaValue modname, LuaValue env) {
	LuaTable math = new LuaTable(0,30);
	math.set("abs", new abs());
	math.set("ceil", new ceil());
	math.set("cos", new cos());
	math.set("deg", new deg());
	math.set("exp", new exp(this));
	math.set("floor", new floor());
	math.set("fmod", new fmod());
	math.set("frexp", new frexp());
	math.set("huge", LuaDouble.POSINF );
	math.set("ldexp", new ldexp());
	math.set("max", new max());
	math.set("min", new min());
	math.set("modf", new modf());
	math.set("pi", Math.PI );
	math.set("pow", new pow());
	random r;
	math.set("random", r = new random());
	math.set("randomseed", new randomseed(r));
	math.set("rad", new rad());
	math.set("sin", new sin());
	math.set("sqrt", new sqrt());
	math.set("tan", new tan());
	env.set("math", math);
	env.get("package").get("loaded").set("math", math);
	return math;
}
 
開發者ID:hsllany,項目名稱:HtmlNative,代碼行數:35,代碼來源:MathLib.java

示例15: invoke

import org.luaj.vm2.LuaValue; //導入方法依賴的package包/類
public Varargs invoke(Varargs args) {
	LuaValue t = tableOf(args, 1);
	t.set("n", args.narg());
	return t;
}
 
開發者ID:hsllany,項目名稱:HtmlNative,代碼行數:6,代碼來源:TableLib.java


注:本文中的org.luaj.vm2.LuaValue.set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。