当前位置: 首页>>代码示例>>Java>>正文


Java LuaClosure类代码示例

本文整理汇总了Java中org.luaj.vm2.LuaClosure的典型用法代码示例。如果您正苦于以下问题:Java LuaClosure类的具体用法?Java LuaClosure怎么用?Java LuaClosure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LuaClosure类属于org.luaj.vm2包,在下文中一共展示了LuaClosure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onDestroyClosure

import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
public static void onDestroyClosure(LuaClosure closure) {
        if (closure != null) {
            if (closure.upValues != null) {
                UpValue upValue = null;
                for (int i = 0; i < closure.upValues.length; i++) {
                    upValue = closure.upValues[i];
//                    if (upValue != null && upValue.array != null) {
//                        for (LuaValue value : upValue.array) {//destroy upvalues
//                            if (value instanceof BaseUserdata) {//userdata destory
//                                ((BaseUserdata) value).onDestroy();
//                            } else if (value instanceof LuaTable) {//destroy table
//                                onDestroyTable((LuaTable) value);
//                            }
//                        }
//                    }
                    closure.upValues[i] = null;
                }
                closure.upValues = null;
            }
        }
    }
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:22,代码来源:DestroyUtil.java

示例2: _setupvalue

import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
static LuaValue _setupvalue(Varargs args)
{
	LuaValue func = args.checkfunction(1);
	int up = args.checkint(2);
	LuaValue value = args.arg(3);
	if(func instanceof LuaClosure)
	{
		LuaClosure c = (LuaClosure)func;
		LuaString name = findupvalue(c, up);
		if(name != null)
		{
			c._upValues[up - 1].setValue(value);
			return name;
		}
	}
	return NIL;
}
 
开发者ID:dwing4g,项目名称:luaj,代码行数:18,代码来源:LibDebug.java

示例3: invoke

import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
public Varargs invoke(Varargs args) {
    LuaValue func = args.checkfunction(1);
    int up = args.checkint(2);
    if (func instanceof LuaClosure) {
        LuaClosure c = (LuaClosure) func;
        LuaString name = findupvalue(c, up);
        if (name != null) {
            return varargsOf(name, c.upValues[up - 1].getValue());
        }
    }
    return NIL;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:13,代码来源:DebugLib.java

示例4: onCall

import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
public void onCall(LuaClosure c, Varargs varargs, LuaValue[] stack) {
    LuaThread t = globals.running;
    callstack().onCall(c, varargs, stack);

    if (t.inhook) return;
    if (t.hookcall && t.hookfunc != null)
        callHook(CALL, NIL);
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:9,代码来源:DebugLib.java

示例5: findupvalue

import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
static LuaString findupvalue(LuaClosure c, int up) {
    if (c.upValues != null && up > 0 && up <= c.upValues.length) {
        if (c.p.upvalues != null && up <= c.p.upvalues.length)
            return c.p.upvalues[up - 1].name;
        else
            return LuaString.valueOf("." + up);
    }
    return null;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:10,代码来源:DebugLib.java

示例6: dump

import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
/**
 * string.dump (function)
 *
 * Returns a string containing a binary representation of the given function,
 * so that a later loadstring on this string returns a copy of the function.
 * function must be a Lua function without upvalues.
 *
 * TODO: port dumping code as optional add-on
 */
static LuaValue dump(LuaValue arg) {
    LuaValue f = arg.checkfunction();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
        DumpState.dump(((LuaClosure) f).p, baos, true);
        return LuaString.valueOf(baos.toByteArray());
    } catch (IOException e) {
        return error(e.getMessage());
    }
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:20,代码来源:StringLib.java

示例7: invoke

import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
public Varargs invoke(Varargs args) {
	LuaValue func = args.checkfunction(1);
	int up = args.checkint(2);
	if ( func instanceof LuaClosure ) {
		LuaClosure c = (LuaClosure) func;
		LuaString name = findupvalue(c, up);
		if ( name != null ) {
			return varargsOf(name, c.upValues[up-1].getValue() );
		}
	}
	return NIL;
}
 
开发者ID:hsllany,项目名称:HtmlNative,代码行数:13,代码来源:DebugLib.java

示例8: findupvalue

import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
static LuaString findupvalue(LuaClosure c, int up) {
	if ( c.upValues != null && up > 0 && up <= c.upValues.length ) {
		if ( c.p.upvalues != null && up <= c.p.upvalues.length )
			return c.p.upvalues[up-1].name;
		else
			return LuaString.valueOf( "."+up );
	}
	return null;
}
 
开发者ID:hsllany,项目名称:HtmlNative,代码行数:10,代码来源:DebugLib.java

示例9: call

import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
public LuaValue call(LuaValue arg) {
	LuaValue f = arg.checkfunction();
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	try {
		DumpState.dump( ((LuaClosure)f).p, baos, true );
		return LuaString.valueUsing(baos.toByteArray());
	} catch (IOException e) {
		return error( e.getMessage() );
	}
}
 
开发者ID:hsllany,项目名称:HtmlNative,代码行数:11,代码来源:StringLib.java

示例10: onCall

import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
public void onCall(LuaClosure c, Varargs varargs, LuaValue[] stack) {
	LuaThread t = globals.running;
	if (t.inhook) return;
	callstack().onCall(c, varargs, stack);
	if (t.hookcall && t.hookfunc != null) 
		callHook(CALL, NIL);
}
 
开发者ID:Cephrus,项目名称:Elite-Armageddon,代码行数:8,代码来源:DebugLib.java

示例11: dump

import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
/** 
 * string.dump (function)
 * 
 * Returns a string containing a binary representation of the given function, 
 * so that a later loadstring on this string returns a copy of the function. 
 * function must be a Lua function without upvalues.
 *  
 * TODO: port dumping code as optional add-on
 */
static LuaValue dump( LuaValue arg ) {
	LuaValue f = arg.checkfunction();
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	try {
		DumpState.dump( ((LuaClosure)f).p, baos, true );
		return LuaString.valueOf(baos.toByteArray());
	} catch (IOException e) {
		return error( e.getMessage() );
	}
}
 
开发者ID:Cephrus,项目名称:Elite-Armageddon,代码行数:20,代码来源:StringLib.java

示例12: _executeImpl

import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
@Override
public boolean _executeImpl(Processor processor) {
	EnvironmentProcessor target = (EnvironmentProcessor)processor;
	
	LuaValue[] args;
	if (_args != null) {
		args = new LuaValue[] { LuaValue.userdataOf(this), LuaValue.valueOf(_function), _args };
	} else {
		args = new LuaValue[] { LuaValue.userdataOf(this), LuaValue.valueOf(_function) };
	}
	
	LuaClosure f = new LuaClosure(_prototype, target.getGlobals());
	f.invoke(LuaTable.listOf(args));
	return true;
}
 
开发者ID:actionk,项目名称:Ragefist,代码行数:16,代码来源:EnvironmentFunctionCallTask.java

示例13: dump

import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
/**
 * string.dump (function)
 *
 * Returns a string containing a binary representation of the given function,
 * so that a later loadstring on this string returns a copy of the function.
 * function must be a Lua function without upvalues.
 *
 * TODO: port dumping code as optional add-on
 */
static LuaValue dump(LuaValue arg)
{
	LuaValue f = arg.checkfunction();
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	try
	{
		DumpState.dump(((LuaClosure)f)._p, baos, true);
		return LuaString.valueOf(baos.toByteArray());
	}
	catch(IOException e)
	{
		return error(e.getMessage());
	}
}
 
开发者ID:dwing4g,项目名称:luaj,代码行数:24,代码来源:LibString.java

示例14: findupvalue

import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
static LuaString findupvalue(LuaClosure c, int up)
{
	if(c._upValues != null && up > 0 && up <= c._upValues.length)
	{
		if(c._p.upvalues != null && up <= c._p.upvalues.length)
		    return c._p.upvalues[up - 1];
		return LuaString.valueOf("." + up);
	}
	return null;
}
 
开发者ID:dwing4g,项目名称:luaj,代码行数:11,代码来源:LibDebug.java

示例15: _getupvalue

import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
static Varargs _getupvalue(Varargs args)
{
	LuaValue func = args.checkfunction(1);
	int up = args.checkint(2);
	if(func instanceof LuaClosure)
	{
		LuaClosure c = (LuaClosure)func;
		LuaString name = findupvalue(c, up);
		if(name != null)
		{
			return varargsOf(name, c._upValues[up - 1].getValue());
		}
	}
	return NIL;
}
 
开发者ID:dwing4g,项目名称:luaj,代码行数:16,代码来源:LibDebug.java


注:本文中的org.luaj.vm2.LuaClosure类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。