示例#1
0
文件: script.go 项目: Abioy/ledisdb
func luaPushError(l *lua.State, msg string) {
	l.NewTable()
	l.PushString("err")
	err := l.NewError(msg)
	l.PushString(err.Error())
	l.SetTable(-3)
}
示例#2
0
文件: script.go 项目: Abioy/ledisdb
func luaSetGlobalArray(l *lua.State, name string, ay [][]byte) {
	l.NewTable()

	for i := 0; i < len(ay); i++ {
		l.PushString(ledis.String(ay[i]))
		l.RawSeti(-2, i+1)
	}

	l.SetGlobal(name)
}
示例#3
0
文件: script.go 项目: Abioy/ledisdb
func luaReturnSingleFieldTable(l *lua.State, filed string) int {
	if l.GetTop() != 1 || l.Type(-1) != lua.LUA_TSTRING {
		luaPushError(l, "wrong number or type of arguments")
		return 1
	}

	l.NewTable()
	l.PushString(filed)
	l.PushValue(-3)
	l.SetTable(-3)
	return 1
}