本文整理匯總了Golang中github.com/aarzilli/golua/lua.State.CheckStack方法的典型用法代碼示例。如果您正苦於以下問題:Golang State.CheckStack方法的具體用法?Golang State.CheckStack怎麽用?Golang State.CheckStack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/aarzilli/golua/lua.State
的用法示例。
在下文中一共展示了State.CheckStack方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: LuaIntColumnQuery
func LuaIntColumnQuery(L *lua.State) int {
if (L.GetTop() != 1) && (L.GetTop() != 3) {
panic(errors.New("Wrong number of arguments to columnq"))
return 0
}
name := L.ToString(1)
op := ""
value := ""
if L.GetTop() == 3 {
op = L.ToString(2)
value = L.ToString(3)
L.Pop(3)
} else {
L.Pop(1)
}
if name[0] == ':' {
panic(errors.New("Column name can not start with ':'"))
return 0
}
L.CheckStack(1)
tl := GetTasklistFromLua(L)
tl.luaState.PushGoStruct(&SimpleExpr{name, op, value, nil, 0, ""})
return 1
}
示例2: GetTasklistFromLua
func GetTasklistFromLua(L *lua.State) *Tasklist {
L.CheckStack(1)
L.GetGlobal(TASKLIST)
rawptr := L.ToUserdata(-1)
var ptr **Tasklist = (**Tasklist)(rawptr)
L.Pop(1)
return *ptr
}
示例3: LuaIntShowRet
func LuaIntShowRet(L *lua.State) int {
L.CheckStack(2)
tl := GetTasklistFromLua(L)
tl.luaFlags.showReturnValue = true
return 0
}
示例4: PushStringVec
func PushStringVec(L *lua.State, v []string) {
L.CheckStack(3)
L.CreateTable(len(v), 0)
for idx, val := range v {
SetTableIntString(L, int64(idx+1), val)
}
}
示例5: LuaIntWriteCursor
func LuaIntWriteCursor(L *lua.State) int {
Logf(INFO, "Writing cursor")
L.CheckStack(1)
tl := GetTasklistFromLua(L)
luaAssertNotFreeCursor(tl, "writecursor()")
cursor := GetEntryFromLua(L, CURSOR, "writecursor()")
tl.Update(cursor, false)
return 0
}
示例6: GetEntryFromLua
func GetEntryFromLua(L *lua.State, name string, fname string) *Entry {
L.CheckStack(1)
L.GetGlobal(name)
rawptr := L.ToUserdata(-1)
var ptr **Entry = (**Entry)(rawptr)
L.Pop(1)
if ptr == nil {
panic(errors.New("No cursor set, can not use " + fname))
}
return *ptr
}
示例7: LuaIntPriorityQuery
func LuaIntPriorityQuery(L *lua.State) int {
luaAssertArgnum(L, 1, "priorityq()")
priority := L.ToString(1)
L.CheckStack(1)
tl := GetTasklistFromLua(L)
tl.luaState.PushGoStruct(&SimpleExpr{":priority", "=", priority, nil, ParsePriority(priority), ""})
return 1
}
示例8: PushTime
func PushTime(L *lua.State, t time.Time) {
L.CheckStack(3)
L.CreateTable(0, 7)
SetTableInt(L, "year", int64(t.Year()))
SetTableInt(L, "month", int64(t.Month()))
SetTableInt(L, "day", int64(t.Day()))
SetTableInt(L, "weekday", int64(t.Weekday()))
SetTableInt(L, "hour", int64(t.Hour()))
SetTableInt(L, "minute", int64(t.Minute()))
SetTableInt(L, "second", int64(t.Second()))
}
示例9: LuaIntStringFunction
func LuaIntStringFunction(L *lua.State, name string, n int, fn func(tl *Tasklist, argv []string) int) int {
luaAssertArgnum(L, n, name)
argv := make([]string, 0)
for i := 1; i <= n; i++ {
argv = append(argv, L.ToString(i))
}
L.Pop(n)
L.CheckStack(1)
tl := GetTasklistFromLua(L)
return fn(tl, argv)
}
示例10: LuaIntTimestamp
func LuaIntTimestamp(L *lua.State) int {
luaAssertArgnum(L, 1, "timestamp()")
if !L.IsTable(-1) {
panic(errors.New("Argoment of timestamp is not a table"))
return 0
}
L.CheckStack(1)
t := time.Date(GetTableInt(L, "year"), time.Month(GetTableInt(L, "month")), GetTableInt(L, "day"), GetTableInt(L, "hour"), GetTableInt(L, "minute"), GetTableInt(L, "second"), 0, time.Local)
L.PushInteger(int64(t.Unix()))
return 1
}
示例11: LuaIntNotQuery
func LuaIntNotQuery(L *lua.State) int {
luaAssertArgnum(L, 1, "Wrong number of arguments to notq")
L.CheckStack(1)
tl := GetTasklistFromLua(L)
clausable := GetQueryObject(tl, -1)
if clausable == nil {
panic(errors.New("Wrong argument type to notq only query objects accepted as arguments"))
return 0
}
tl.luaState.PushGoStruct(&NotExpr{clausable})
return 1
}
示例12: LuaIntParseDateTime
func LuaIntParseDateTime(L *lua.State) int {
luaAssertArgnum(L, 1, "parsedatetime()")
L.CheckStack(1)
input := L.ToString(-1)
tl := GetTasklistFromLua(L)
out, _ := ParseDateTime(input, tl.GetTimezone())
if out != nil {
L.PushInteger(int64(out.Unix()))
} else {
L.PushInteger(0)
}
return 1
}
示例13: LuaIntBoolQuery
func LuaIntBoolQuery(L *lua.State, operator, name string) int {
if L.GetTop() < 2 {
panic(errors.New("Wrong number of arguments to " + name))
return 0
}
L.CheckStack(1)
tl := GetTasklistFromLua(L)
r := &BoolExpr{operator, make([]Clausable, 0)}
for i := 1; i <= L.GetTop(); i++ {
clausable := GetQueryObject(tl, i)
if clausable == nil {
panic(errors.New("Wrong argument type to " + name + " only query objects accepted as arguments"))
return 0
}
r.subExpr = append(r.subExpr, clausable)
}
tl.luaState.PushGoStruct(r)
return 1
}
示例14: LuaIntSearch
func LuaIntSearch(L *lua.State) int {
if (L.GetTop() < 1) || (L.GetTop() > 2) {
panic(errors.New("Wrong number of arguments to search()"))
return 0
}
L.CheckStack(2)
tl := GetTasklistFromLua(L)
if !tl.luaFlags.freeCursor {
panic(errors.New("search() function only available on a free cursor"))
return 0
}
query := L.ToString(1)
var luaClausable Clausable = nil
if L.GetTop() == 2 {
luaClausable = GetQueryObject(tl, 2)
}
theselect, _, _, _, _, _, _, perr := tl.ParseSearch(query, luaClausable)
Must(perr)
entries, serr := tl.Retrieve(theselect, "", false)
Must(serr)
Logf(INFO, "Searching from lua interface <%s> clausable: <%v> yields %d results\n", query, luaClausable, len(entries))
r := []string{}
for _, entry := range entries {
r = append(r, entry.Id())
}
PushStringVec(L, r)
return 1
}
示例15: LuaIntVisit
func LuaIntVisit(L *lua.State) int {
L.CheckStack(1)
tl := GetTasklistFromLua(L)
luaAssertNotFreeCursor(tl, "visit()")
id := L.ToString(1)
Logf(DEBUG, "Lua visiting: <%s>\n", id)
var error interface{} = nil
{
defer func() {
if rerr := recover(); rerr != nil {
error = rerr
}
}()
cursor := tl.Get(id)
tl.SetEntryInLua(CURSOR, cursor)
}
if error != nil {
tl.SetEntryInLua(CURSOR, nil)
}
return 0
}