# (c) 2021 Ashok P. Nadkarni
# See LICENSE for license terms.

namespace eval ${NS}::type {
    proc size {type args} {
        # Returns the size of a type in terms of the number of bytes of memory
        # occupied by that type.
        #  type - a type definition or alias
        #  -vlacount VLACOUNT - number of elements in variable size array
        # In the case of array types, the size includes the size of the entire
        # array and not the size of a single element.
        #
        # The option `-vlacount` must be specified if the type is variable
        # length array or a struct that contains a variable length array
    }
    proc count {type} {
        # Returns the count of elements in an array type
        #  type - a type definition or alias
        # A return value of `-1` indicates the type is not an array.
    }
    proc info {typedecl args} {
        # Returns a dictionary containing various information about a type
        # declaration
        #   typedecl - a type declaration
        #   -parsemode MODE - one of `param`, `return`, `field`.
        #   -vlacount VLACOUNT - number of elements in variable size array
        #
        # The type is parsed as a parameter type declaration, a function return
        # type declaration or a structure field type declaration depending
        # on the `-parsemode` option. If this is unspecified or an empty
        # string, it is parsed in generic fashion and no context-specific
        # validation is done.
        #
        # The option `-vlacount` must be specified if the type is variable
        # length array or a struct that contains a variable length array
        #
        # The returned dictionary contains the following keys:
        #
        # Alignment - the memory alignment needed for a value of that type
        # BaseSize - the number of bytes to store a single value of the type
        #  when the type is an array. For scalars, same as `Size`.
        # Count - `-1` for scalar values, else indicates the type is an array
        #  with that number of elements
        # Size - the number of bytes of memory needed to store a value of that
        #  type.
        # Definition - the type declaration after applying any defaults.
        #  For type aliases, this is the resolved type definition.
    }
    proc tobinary {typespec value} {
        # Converts a script level value to a native representation.
        # typespec - a type declaration
        # value - the script level value
        #
        # The $typespec argument must not have a string or variable size
        # component. If an array is specified of a larger size than the number
        # of elements in $value, the remaining elements are zeroed out.
        #
        # Returns a Tcl binary containing the native representation.
        # See also: "type frombinary"
    }
    proc frombinary {typespec value} {
        # Converts the native binary value to its script level representation.
        # typespec - a type declaration
        # value - the native binary value
        #
        # The $typespec argument may be any type specification.
        #
        # Returns the script level representation of the value.
        # See also: "type tobinary"
    }

    namespace export *
    namespace ensemble create
}

