Browse Source

API generator understands new types;

bjorn 2 weeks ago
parent
commit
2baf995d6c
4 changed files with 16 additions and 13 deletions
  1. 3 3
      api/init.lua
  2. 1 1
      api/lovr/data/newSound.lua
  3. 2 2
      api/lovr/graphics/submit.lua
  4. 10 7
      api/main.lua

+ 3 - 3
api/init.lua

@@ -3797,7 +3797,7 @@ return {
                 },
                 {
                   name = "contents",
-                  type = "Blob | 'stream' | nil",
+                  type = "Blob | string | nil",
                   description = "A Blob containing raw audio samples to use as the initial contents, 'stream' to create an audio stream, or `nil` to leave the data initialized to zero.",
                   default = "nil"
                 }
@@ -12391,7 +12391,7 @@ return {
               arguments = {
                 {
                   name = "...",
-                  type = "Pass | false | nil",
+                  type = "Pass | boolean | nil",
                   description = "The pass objects to submit.  Falsy values will be skipped."
                 }
               },
@@ -12407,7 +12407,7 @@ return {
               arguments = {
                 {
                   name = "t",
-                  type = "{Pass | false}",
+                  type = "{Pass | boolean}",
                   description = "A table of passes to submit.  Falsy values will be skipped."
                 }
               },

+ 1 - 1
api/lovr/data/newSound.lua

@@ -33,7 +33,7 @@ return {
       description = 'The sample rate, in Hz.'
     },
     contents = {
-      type = [[Blob | 'stream' | nil]],
+      type = [[Blob | string | nil]],
       default = 'nil',
       description = [[
         A Blob containing raw audio samples to use as the initial contents, 'stream' to create an

+ 2 - 2
api/lovr/graphics/submit.lua

@@ -4,11 +4,11 @@ return {
   description = 'Submits work to the GPU.',
   arguments = {
     ['...'] = {
-      type = 'Pass | false | nil',
+      type = 'Pass | boolean | nil',
       description = 'The pass objects to submit.  Falsy values will be skipped.'
     },
     t = {
-      type = '{Pass | false}',
+      type = '{Pass | boolean}',
       description = 'A table of passes to submit.  Falsy values will be skipped.'
     }
   },

+ 10 - 7
api/main.lua

@@ -301,10 +301,13 @@ end
 local function validateType(type, fields, key, kind)
   if not type then
     warn('Missing %s type in %s', kind, key)
-  elseif type:match('^[A-Z]') then
-    warnIf(not lookup[type], 'Invalid %s type "%s" in %s', kind, type, key)
+  elseif type == 'table' and fields then
+    for i, field in ipairs(fields) do
+      validateType(field.type, field.table, key, kind)
+    end
   else
     local valid = {
+      ['nil'] = true,
       boolean = true,
       number = true,
       table = true,
@@ -315,11 +318,11 @@ local function validateType(type, fields, key, kind)
       ['*'] = true
     }
 
-    warnIf(not valid[type], 'Invalid %s type "%s" in %s', kind, type, key)
-
-    if type == 'table' and fields then
-      for i, field in ipairs(fields) do
-        validateType(field.type, field.table, key, kind)
+    for word in type:gmatch('%w+') do
+      if word:match('^[A-Z]') then
+        warnIf(not lookup[word], 'Invalid %s type "%s" in %s', kind, word, key)
+      else
+        warnIf(not valid[word], 'Invalid %s type "%s" in %s', kind, word, key)
       end
     end
   end