metatable.lua 616 B

12345678910111213
  1. -- Registered metatables, used by the C++ packer
  2. local known_metatables = {}
  3. function core.register_async_metatable(name, mt)
  4. assert(type(name) == "string", ("attempt to use %s value as metatable name"):format(type(name)))
  5. assert(type(mt) == "table", ("attempt to register a %s value as metatable"):format(type(mt)))
  6. assert(known_metatables[name] == nil or known_metatables[name] == mt,
  7. ("attempt to override metatable %s"):format(name))
  8. known_metatables[name] = mt
  9. known_metatables[mt] = name
  10. end
  11. core.known_metatables = known_metatables
  12. core.register_async_metatable("__builtin:vector", vector.metatable)