本文整理汇总了Golang中github.com/kdar/morphgen/golua/lua.State.PushValue方法的典型用法代码示例。如果您正苦于以下问题:Golang State.PushValue方法的具体用法?Golang State.PushValue怎么用?Golang State.PushValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/kdar/morphgen/golua/lua.State
的用法示例。
在下文中一共展示了State.PushValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GoLua
func GoLua(L *lua.State) int {
go func() {
LT := L.NewThread()
L.PushValue(1)
lua.XMove(L, LT, 1)
res := LT.Resume(0)
for res != 0 {
if res == 2 {
emsg := LT.ToString(-1)
fmt.Println("error", emsg)
}
ch, t := valueOfProxy(LT, -2)
if LT.ToBoolean(-1) { // send on a channel
val := valueOf(LuaToGo(LT, t.Elem(), -3))
ch.Send(val)
res = LT.Resume(0)
} else { // receive on a channel
val, ok := ch.Recv()
GoToLua(LT, t.Elem(), val)
LT.PushBoolean(ok)
res = LT.Resume(2)
}
}
}()
return 0
}
示例2: Lookup
// look up a Lua value by its full name. If idx is 0, then this name
// is assumed to start in the global table, e.g. "string.gsub".
// With non-zero idx, can be used to look up subfields of a table
func Lookup(L *lua.State, path string, idx int) {
parts := strings.Split(path, ".")
if idx != 0 {
L.PushValue(idx)
} else {
L.GetGlobal("_G")
}
for _, field := range parts {
L.GetField(-1, field)
L.Remove(-2) // remove table
}
}
示例3: channel_send
func channel_send(L *lua.State) int {
fmt.Println("yield send")
L.PushValue(2)
L.PushValue(1)
L.PushBoolean(true)
return L.Yield(3)
//~ ch,t := valueOfProxy(L,1)
//~ val := valueOf(LuaToGo(L, t.Elem(),2))
//~ ch.Send(val)
//~ return 0
}
示例4: channel_recv
func channel_recv(L *lua.State) int {
fmt.Println("yield recv")
L.PushValue(1)
L.PushBoolean(false)
return L.Yield(2)
//~ ch,t := valueOfProxy(L,1)
//~ L.Yield(0)
//~ val,ok := ch.Recv()
//~ GoToLua(L,t.Elem(),val)
//~ L.PushBoolean(ok)
//~ L.Resume(0)
//~ return 2
}
示例5: NewLuaObject
// create a new LuaObject using the given state and stack index.
func NewLuaObject(L *lua.State, idx int) *LuaObject {
tp := L.LTypename(idx)
L.PushValue(idx)
ref := L.Ref(lua.LUA_REGISTRYINDEX)
return &LuaObject{L, ref, tp}
}