-
Notifications
You must be signed in to change notification settings - Fork 203
/
api_push.go
57 lines (48 loc) · 1.38 KB
/
api_push.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package state
import . "luago/api"
// [-0, +1, –]
// http://www.lua.org/manual/5.3/manual.html#lua_pushnil
func (self *luaState) PushNil() {
self.stack.push(nil)
}
// [-0, +1, –]
// http://www.lua.org/manual/5.3/manual.html#lua_pushboolean
func (self *luaState) PushBoolean(b bool) {
self.stack.push(b)
}
// [-0, +1, –]
// http://www.lua.org/manual/5.3/manual.html#lua_pushinteger
func (self *luaState) PushInteger(n int64) {
self.stack.push(n)
}
// [-0, +1, –]
// http://www.lua.org/manual/5.3/manual.html#lua_pushnumber
func (self *luaState) PushNumber(n float64) {
self.stack.push(n)
}
// [-0, +1, m]
// http://www.lua.org/manual/5.3/manual.html#lua_pushstring
func (self *luaState) PushString(s string) {
self.stack.push(s)
}
// [-0, +1, –]
// http://www.lua.org/manual/5.3/manual.html#lua_pushcfunction
func (self *luaState) PushGoFunction(f GoFunction) {
self.stack.push(newGoClosure(f, 0))
}
// [-n, +1, m]
// http://www.lua.org/manual/5.3/manual.html#lua_pushcclosure
func (self *luaState) PushGoClosure(f GoFunction, n int) {
closure := newGoClosure(f, n)
for i := n; i > 0; i-- {
val := self.stack.pop()
closure.upvals[i-1] = &upvalue{&val}
}
self.stack.push(closure)
}
// [-0, +1, –]
// http://www.lua.org/manual/5.3/manual.html#lua_pushglobaltable
func (self *luaState) PushGlobalTable() {
global := self.registry.get(LUA_RIDX_GLOBALS)
self.stack.push(global)
}