diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-08-14 08:56:18 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2025-03-02 14:24:49 +0000 |
| commit | 7a7db7e0b2f3782a90528f6dbdf84ecd0ce47291 (patch) | |
| tree | 9a024d9b3fa7bd993462bec5a177d3314dcbc4df /alv/type.moon | |
| parent | add vis/rgb (diff) | |
| download | alive-7a7db7e0b2f3782a90528f6dbdf84ecd0ce47291.tar.gz alive-7a7db7e0b2f3782a90528f6dbdf84ecd0ce47291.zip | |
document and spec Type member fields
Diffstat (limited to 'alv/type.moon')
| -rw-r--r-- | alv/type.moon | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/alv/type.moon b/alv/type.moon index 7aeb29a..1b47b13 100644 --- a/alv/type.moon +++ b/alv/type.moon @@ -22,6 +22,17 @@ same = (a, b) -> true +local Primitive + +--- Magic table containing all `Primitive` types. +-- +-- When indexed with a string returns a (cached) instance of that type. +-- +-- @table T +T = setmetatable {}, __index: (key) => + with type = Primitive key + rawset @, key, type + --- Base class for types. -- @type Type class Type @@ -84,6 +95,9 @@ class Primitive extends Type new: (@name) => assert (type @name) == 'string', "Typename has to be a string: '#{@name}'" + --- the type's unique name. + -- @tfield string name + --- Struct/Hashmap type. -- -- Extends `Type`. @@ -122,6 +136,9 @@ class Struct extends Type -- @tparam {string=Type} types new: (@types) => + --- the shape and field types of the struct. + -- @tfield {string=Type} types + --- Array type. -- -- Extends `Type`. @@ -153,14 +170,11 @@ class Array extends Type -- @tparam Type type new: (@size, @type) => ---- Magic table containing all `Primitive` types. --- --- When indexed with a string returns a (cached) instance of that type. --- --- @table T -T = setmetatable {}, __index: (key) => - with type = Primitive key - rawset @, key, type + --- the number of elements in this array. + -- @tfield number size + + --- the element type of this array. + -- @tfield Type type { :Type |
