Documentation
¶
Overview ¶
Code generated by gobindlua; DO NOT EDIT.
Code generated by gobindlua; DO NOT EDIT.
Code generated by gobindlua; DO NOT EDIT.
Code generated by gobindlua; DO NOT EDIT.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mammal ¶
type Mammal interface {
Sound() string
gobindlua.LuaUserData
}
type MammalList ¶
Example ¶
package main
import (
"log"
"github.com/ChrisTrenkamp/gobindlua"
lua "github.com/yuin/gopher-lua"
)
const script = `
--[[
Implement gobindlua.LuaUserData in order to pass interfaces
around in GopherLua. The interface implementation doesn't necessarily
need to be generated with gobindlua, but its metadata table must be
globally available. Otherwise, it will not work.
]]
local mammals = mammal_list.new()
mammals.pet = dog.new()
mammals.non_pets = { lion.new(), human.new() }
print("My pet says: " .. mammals.pet:sound())
print("The other mammals say:")
for i=1,#mammals.non_pets,1 do
print(mammals.non_pets[i]:sound())
end
`
func main() {
L := lua.NewState()
defer L.Close()
Dog{}.RegisterLuaType(L)
Lion{}.RegisterLuaType(L)
Human{}.RegisterLuaType(L)
MammalList{}.RegisterLuaType(L)
gobindlua.RegisterLuaArray(L)
if err := L.DoString(script); err != nil {
log.Fatal(err)
}
}
Output: My pet says: bark The other mammals say: rawr burp
func NewMammalList ¶
func NewMammalList() MammalList
func (*MammalList) LuaMetatableType ¶
func (r *MammalList) LuaMetatableType() string
func (MammalList) RegisterLuaType ¶
func (goType MammalList) RegisterLuaType(L *lua.LState)
Click to show internal directories.
Click to hide internal directories.