本文整理匯總了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)
}
}
}
}