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)
| 247 | // In both cases it pushes onto the stack the final value associated with name in |
| 248 | // the registry. |
| 249 | func 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 | |
| 260 | func MetaTableNamed(l *State, name string) { |
| 261 | l.Field(RegistryIndex, name) |