本文整理匯總了Golang中C.lua_pushinteger函數的典型用法代碼示例。如果您正苦於以下問題:Golang lua_pushinteger函數的具體用法?Golang lua_pushinteger怎麽用?Golang lua_pushinteger使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了lua_pushinteger函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: goToLuaValue
func (state State) goToLuaValue(value reflect.Value) bool {
L := state.L
gkind := value.Kind()
switch gkind {
case reflect.Bool:
v := value.Bool()
if v {
C.lua_pushboolean(L, 1)
} else {
C.lua_pushboolean(L, 0)
}
return true
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
v := value.Int()
C.lua_pushinteger(L, C.lua_Integer(v))
return true
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
v := value.Uint()
C.lua_pushinteger(L, C.lua_Integer(v))
return true
// case reflect.Uintptr:
case reflect.Float32, reflect.Float64:
v := value.Float()
C.lua_pushnumber(L, C.lua_Number(v))
return true
// case reflect.Array:
// case reflect.Complex64, reflect.Complex128:
// case reflect.Chan
// case reflect.Interface
case reflect.Ptr:
iv := value.Interface()
if v, ok := iv.(ILuaRef); ok {
v.PushValue(state)
return true
}
state.pushObjToLua(value.Interface())
return true
case reflect.Func, reflect.Map, reflect.Slice:
state.pushObjToLua(value.Interface())
return true
case reflect.String:
v := value.String()
pushStringToLua(L, v)
return true
case reflect.Struct:
objPtr := reflect.New(value.Type())
objPtr.Elem().Set(value)
state.pushObjToLua(objPtr.Interface())
return true
//case reflect.UnsafePointer
case reflect.Interface:
return state.goToLuaValue(value.Elem())
}
C.lua_pushnil(L)
return false
}
示例2: UnpackToLua
func UnpackToLua(in io.Reader, state State) int {
L := state.L
var n int = 0
var unpack P.Unpacker
msg, err := unpack.Unpack(in)
if err != nil {
C.lua_pushinteger(L, C.lua_Integer(n))
pushStringToLua(L, fmt.Sprintf("unpack error: %v", err))
return 2
}
n = len(msg.Elems)
C.lua_pushinteger(L, C.lua_Integer(n))
for _, elem := range msg.Elems {
UnpackObjectToLua(state, elem)
}
return n + 1
}
示例3: GO_getObjectLength
//export GO_getObjectLength
func GO_getObjectLength(_L unsafe.Pointer, ref unsafe.Pointer) (ret int) {
L := (*C.lua_State)(_L)
node := (*refGo)(ref)
// vm := node.vm
// state := State{vm, L}
v := reflect.ValueOf(node.obj)
defer func() {
if r := recover(); r != nil {
pushStringToLua(L, fmt.Sprintf("%v", r))
ret = -1
}
}()
n := v.Len()
C.lua_pushinteger(L, C.lua_Integer(n))
return 1
}
示例4: PushInteger
// lua_pushinteger
func (L *State) PushInteger(n int64) {
C.lua_pushinteger(L.s, C.lua_Integer(n))
}
示例5: Pushinteger
// Pushes a number with value n onto the stack.
func (s *State) Pushinteger(n int) {
C.lua_pushinteger(s.l, C.lua_Integer(n))
}
示例6: pushInt
func (L *State) pushInt(i int64) {
C.lua_pushinteger(L.s, C.lua_Integer(i))
}