本文整理汇总了Golang中github.com/kdar/morphgen/golua/lua.State.PushBoolean方法的典型用法代码示例。如果您正苦于以下问题:Golang State.PushBoolean方法的具体用法?Golang State.PushBoolean怎么用?Golang State.PushBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/kdar/morphgen/golua/lua.State
的用法示例。
在下文中一共展示了State.PushBoolean方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例2: 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
}
示例3: initializeProxies
func initializeProxies(L *lua.State) {
flagValue := func() {
L.PushBoolean(true)
L.SetField(-2, "luago.value")
L.Pop(1)
}
L.NewMetaTable(SLICE_META)
L.SetMetaMethod("__index", slice__index)
L.SetMetaMethod("__newindex", slice__newindex)
L.SetMetaMethod("__len", slicemap__len)
flagValue()
L.NewMetaTable(MAP_META)
L.SetMetaMethod("__index", map__index)
L.SetMetaMethod("__newindex", map__newindex)
L.SetMetaMethod("__len", slicemap__len)
flagValue()
L.NewMetaTable(STRUCT_META)
L.SetMetaMethod("__index", struct__index)
L.SetMetaMethod("__newindex", struct__newindex)
flagValue()
L.NewMetaTable(INTERFACE_META)
L.SetMetaMethod("__index", interface__index)
flagValue()
L.NewMetaTable(CHANNEL_META)
//~ RegisterFunctions(L,"*",FMap {
//~ "Send":channel_send,
//~ "Recv":channel_recv,
//~ })
L.NewTable()
L.PushGoFunction(channel_send)
L.SetField(-2, "Send")
L.PushGoFunction(channel_recv)
L.SetField(-2, "Recv")
L.SetField(-2, "__index")
flagValue()
}
示例4: GoToLua
// Push a Go value 'val' of type 't' on the Lua stack.
// If we haven't been given a concrete type, use the type of the value
// and unbox any interfaces.
func GoToLua(L *lua.State, t reflect.Type, val reflect.Value) {
proxify := true
if !val.IsValid() || val.IsNil() {
L.PushNil()
return
}
if t == nil {
t = val.Type()
if t.Kind() == reflect.Interface { // unbox interfaces!
val = valueOf(val.Interface())
t = val.Type()
}
proxify = false
}
if t.Kind() == reflect.Ptr {
t = t.Elem()
}
switch t.Kind() {
case reflect.Float64:
case reflect.Float32:
{
L.PushNumber(val.Float())
}
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32:
{
L.PushNumber(float64(val.Int()))
}
case reflect.Uint, reflect.Uint8:
{
L.PushNumber(float64(val.Uint()))
}
case reflect.String:
{
L.PushString(val.String())
}
case reflect.Bool:
{
L.PushBoolean(val.Bool())
}
case reflect.Slice:
{
if proxify {
makeValueProxy(L, val, SLICE_META)
} else {
CopySliceToTable(L, val)
}
}
case reflect.Map:
{
if proxify {
makeValueProxy(L, val, MAP_META)
} else {
CopyMapToTable(L, val)
}
}
case reflect.Struct:
{
if v, ok := val.Interface().(error); ok {
L.PushString(v.Error())
} else {
makeValueProxy(L, val, STRUCT_META)
}
}
default:
{
if v, ok := val.Interface().(error); ok {
L.PushString(v.Error())
} else if val.IsNil() {
L.PushNil()
} else {
makeValueProxy(L, val, INTERFACE_META)
}
}
}
}