`BlockEnums.BlockEnum`

— Type`BlockEnum{T<:Integer}`

The abstract supertype of all enumerated types defined with `@blockenum`

.

`Base.instances`

— Method`instances(t::Type{<:BlockEnum})`

Return a `Tuple`

of all of the named values of `t`

.

`BlockEnums.addblocks!`

— Function`addblocks!(t::Type{<:BlockEnum}), nblocks::Integer)`

Add and initialize `nblocks`

blocks to the bookkeeping for `t`

. The number of active blocks for the type is returned.

`BlockEnums.basetype`

— Method`basetype(V::Type{<:BlockEnum{T}})`

Return `T`

, which is the bitstype whose values are bitcast to the type `V`

. This is the type of the value returned by `Integer(x::V)`

. The type is in a sense the underlying type of `V`

.

`BlockEnums.blockindex`

— Function`blockindex(v::BlockEnum)`

Get the index of the block of values `v`

belongs to.

`BlockEnums.blocklength`

— Function`blocklength(t::Type{<:BlockEnum})`

Get the length of blocks that the range of values of `t`

is partitioned into.

`BlockEnums.blockrange`

— Method`blockrange(t::Type{<:BlockEnum}, blockind)`

Return the range of values of `t`

in block number `blockind`

.

`BlockEnums.compact_show`

— Function`compact_show(t::Type{<:BlockEnum})`

Return `true`

if compact show was set when `t`

was defined. This omits printing the corresponding integer when printing. To enable compact show, include the key/val pair `compactshow=true`

when defining `t`

.

`BlockEnums.getmodule`

— Function`getmodule(t::Type{<:BlockEnum})`

Get the module in which `t`

is defined.

`BlockEnums.maxvalind`

— Function`maxvalind(t::Type{<:BlockEnum}, block_num::Integer)`

Return the largest index for which a name has been assigned in the `block_num`

th block `t`

. This number is constrained to be within the values in the block.

`BlockEnums.namemap`

— Function`namemap(::Type{<:BlockEnum})`

Return the `Dict`

mapping all values to name symbols. Perhaps this should not be advertized or exposed.

`BlockEnums.numblocks`

— Function`numblocks(t::Type{<:BlockEnum{T}}) where T <: Integer`

Return the number of blocks for which bookkeeping has been set up. The set of values of `t`

is the nonzero values of `T`

, which is typically very large. Bookkeeping of blocks requires storage. So you can only set up some of the blocks for use.

`BlockEnums.setblocklength!`

— Function`setblocklength!(t::Type{<:BlockEnum}, block_length)`

Set the length of each block in the partition of the values of `t`

. This can only be called once. In order to use the blocks you must first set up bookkeeping by calling `addblocks!`

. These blocks are called "active".

`BlockEnums.val`

— Method`val(x::BlockEnum{T})`

Return `x`

bitcast to type `T`

.

`BlockEnums.@blockenum`

— Macro`@blockenum BlockEnumName[::BaseType] value1[=x] value2[=y]`

Create an `BlockEnum{BaseType}`

subtype with name `BlockEnumName`

and enum member values of `value1`

and `value2`

with optional assigned values of `x`

and `y`

, respectively. `BlockEnumName`

can be used just like other types and enum member values as regular values, such as

**Examples**

```
julia> @blockenum Fruit apple=1 orange=2 kiwi=3
julia> f(x::Fruit) = "I'm a Fruit with value: $(Int(x))"
f (generic function with 1 method)
julia> f(apple)
"I'm a Fruit with value: 1"
julia> Fruit(1)
apple::Fruit = 1
```

Values can also be specified inside a `begin`

block, e.g.

```
@blockenum BlockEnumName begin
value1
value2
end
```

`BaseType`

, which defaults to `Int32`

, must be a primitive subtype of `Integer`

. Member values can be converted between the enum type and `BaseType`

. `read`

and `write`

perform these conversions automatically. In case the enum is created with a non-default `BaseType`

, `Integer(value1)`

will return the integer `value1`

with the type `BaseType`

.

To list all the instances of an enum use `instances`

, e.g.

```
julia> instances(Fruit)
(apple, orange, kiwi)
```

It is possible to construct a symbol from an enum instance:

```
julia> Symbol(apple)
:apple
```