MCPcopy Index your code
hub / github.com/Shopify/go-lua / NewMetaTable

Function NewMetaTable

auxiliary.go:249–258  ·  view source on GitHub ↗

NewMetaTable returns false if the registry already has the key name. Otherwise, creates a new table to be used as a metatable for userdata, adds it to the registry with key name, and returns true. In both cases it pushes onto the stack the final value associated with name in the registry.

(l *State, name string)

Source from the content-addressed store, hash-verified

247// In both cases it pushes onto the stack the final value associated with name in
248// the registry.
249func NewMetaTable(l *State, name string) bool {
250 if MetaTableNamed(l, name); !l.IsNil(-1) {
251 return false
252 }
253 l.Pop(1)
254 l.NewTable()
255 l.PushValue(-1)
256 l.SetField(RegistryIndex, name)
257 return true
258}
259
260func MetaTableNamed(l *State, name string) {
261 l.Field(RegistryIndex, name)

Callers 1

IOOpenFunction · 0.85

Calls 6

MetaTableNamedFunction · 0.85
IsNilMethod · 0.80
PopMethod · 0.80
NewTableMethod · 0.80
PushValueMethod · 0.80
SetFieldMethod · 0.80

Tested by

no test coverage detected