diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/type/rockspec.tl | 13 | ||||
| -rw-r--r-- | src/luarocks/type_check.lua | 12 | ||||
| -rw-r--r-- | src/luarocks/type_check.tl | 14 |
3 files changed, 26 insertions, 13 deletions
diff --git a/src/luarocks/type/rockspec.tl b/src/luarocks/type/rockspec.tl index 26f29587..fab87fd4 100644 --- a/src/luarocks/type/rockspec.tl +++ b/src/luarocks/type/rockspec.tl | |||
| @@ -10,6 +10,19 @@ local util = require("luarocks.core.util") --! | |||
| 10 | 10 | ||
| 11 | type_rockspec.rockspec_format = "3.0" | 11 | type_rockspec.rockspec_format = "3.0" |
| 12 | 12 | ||
| 13 | -- Syntax for type-checking tables: | ||
| 14 | -- | ||
| 15 | -- A type-checking table describes typing data for a value. | ||
| 16 | -- Any key starting with an underscore has a special meaning: | ||
| 17 | -- _type (string) is the Lua type of the value. Default is "table". | ||
| 18 | -- _mandatory (boolean) indicates if the value is a mandatory key in its container table. Default is false. | ||
| 19 | -- For "string" types only: | ||
| 20 | -- _pattern (string) is the string-matching pattern, valid for string types only. Default is ".*". | ||
| 21 | -- For "table" types only: | ||
| 22 | -- _any (table) is the type-checking table for unspecified keys, recursively checked. | ||
| 23 | -- _more (boolean) indicates that the table accepts unspecified keys and does not type-check them. | ||
| 24 | -- Any other string keys that don't start with an underscore represent known keys and are type-checking tables, recursively checked. | ||
| 25 | |||
| 13 | local rockspec_formats, versions = type_check.declare_schemas({ | 26 | local rockspec_formats, versions = type_check.declare_schemas({ |
| 14 | ["1.0"] = { | 27 | ["1.0"] = { |
| 15 | fields = { | 28 | fields = { |
diff --git a/src/luarocks/type_check.lua b/src/luarocks/type_check.lua index 77f9ef24..50eceddf 100644 --- a/src/luarocks/type_check.lua +++ b/src/luarocks/type_check.lua | |||
| @@ -31,9 +31,9 @@ type_check.MAGIC_PLATFORMS = {} | |||
| 31 | do | 31 | do |
| 32 | local function fill_in_version(tbl, version) | 32 | local function fill_in_version(tbl, version) |
| 33 | 33 | ||
| 34 | if not tbl.fields then | 34 | |
| 35 | return | 35 | |
| 36 | end | 36 | |
| 37 | 37 | ||
| 38 | for _, v in pairs(tbl.fields) do | 38 | for _, v in pairs(tbl.fields) do |
| 39 | if type(v) == "table" then | 39 | if type(v) == "table" then |
| @@ -191,10 +191,10 @@ function type_check.type_check_table(version, tbl, typetbl, context) | |||
| 191 | return nil, errcheck | 191 | return nil, errcheck |
| 192 | end | 192 | end |
| 193 | 193 | ||
| 194 | if not typetbl.fields then | ||
| 195 | 194 | ||
| 196 | return true | 195 | |
| 197 | end | 196 | |
| 197 | |||
| 198 | 198 | ||
| 199 | for k, v in pairs(tbl) do | 199 | for k, v in pairs(tbl) do |
| 200 | local t = typetbl.fields[tostring(k)] or typetbl._any | 200 | local t = typetbl.fields[tostring(k)] or typetbl._any |
diff --git a/src/luarocks/type_check.tl b/src/luarocks/type_check.tl index 7c3c4064..6b5dbb16 100644 --- a/src/luarocks/type_check.tl +++ b/src/luarocks/type_check.tl | |||
| @@ -31,9 +31,9 @@ type_check.MAGIC_PLATFORMS = {} | |||
| 31 | do | 31 | do |
| 32 | local function fill_in_version(tbl: TableSchema, version?: string) | 32 | local function fill_in_version(tbl: TableSchema, version?: string) |
| 33 | 33 | ||
| 34 | if not tbl.fields then --! validation | 34 | -- if not tbl.fields then --! validation |
| 35 | return | 35 | -- return |
| 36 | end | 36 | -- end |
| 37 | 37 | ||
| 38 | for _, v in pairs(tbl.fields) do | 38 | for _, v in pairs(tbl.fields) do |
| 39 | if v is TableSchema then | 39 | if v is TableSchema then |
| @@ -191,10 +191,10 @@ function type_check.type_check_table(version: string, tbl: {any: any}, typetbl: | |||
| 191 | return nil, errcheck | 191 | return nil, errcheck |
| 192 | end | 192 | end |
| 193 | 193 | ||
| 194 | if not typetbl.fields then --! validation | 194 | -- if not typetbl.fields then --! validation |
| 195 | -- if there are no fields, exit the checker | 195 | -- -- if there are no fields, exit the checker |
| 196 | return true | 196 | -- return true |
| 197 | end | 197 | -- end |
| 198 | 198 | ||
| 199 | for k, v in pairs(tbl) do | 199 | for k, v in pairs(tbl) do |
| 200 | local t = typetbl.fields[tostring(k)] or typetbl._any --! tostring | 200 | local t = typetbl.fields[tostring(k)] or typetbl._any --! tostring |
