metatable.lua 844 B

12345678910111213141516171819
  1. -- Registered metatables, used by the C++ packer
  2. local known_metatables = {}
  3. function core.register_portable_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. function core.register_async_metatable(...)
  13. core.log("deprecated", "core.register_async_metatable is deprecated. " ..
  14. "Use core.register_portable_metatable instead.")
  15. return core.register_portable_metatable(...)
  16. end
  17. core.register_portable_metatable("__builtin:vector", vector.metatable)