Browse Source

Try adding Object superclass;

bjorn 3 years ago
parent
commit
ad6fbcf503
2 changed files with 27 additions and 0 deletions
  1. 11 0
      api/lovr/Object/init.lua
  2. 16 0
      api/lovr/Object/release.lua

+ 11 - 0
api/lovr/Object/init.lua

@@ -0,0 +1,11 @@
+return {
+  summary = 'The base object.',
+  description = [[
+    This is not a real object, but describes the behavior shared by all objects.  Think of it as the
+    superclass of all LÖVR objects.
+
+    In addition to the methods here, all objects have a `__tostring` metamethod that returns the
+    name of the object's type.  So to check if a LÖVR object is an instance of "Blob", you can do
+    `tostring(object) == 'Blob'`.
+  ]]
+}

+ 16 - 0
api/lovr/Object/release.lua

@@ -0,0 +1,16 @@
+return {
+  summary = 'Immediately release the Lua reference to an object.',
+  description = [[
+    Immediately destroys Lua's reference to the object it's called on.  After calling this function
+    on an object, it is an error to do anything with the object from Lua (call methods on it, pass
+    it to other functions, etc.).  If nothing else is using the object, it will be destroyed
+    immediately, which can be used to destroy something earlier than it would normally be garbage
+    collected in order to reduce memory.
+  ]],
+  arguments = {},
+  returns = {},
+  notes = [[
+    The object may not be destroyed immediately if something else is referring to it (e.g. it is
+    pushed to a Channel or exists in the payload of a pending event).
+  ]]
+}