mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Deprecate MyEnum.elements.
This commit is contained in:
@@ -6,7 +6,7 @@ import std::io;
|
||||
|
||||
struct EnumMap (Printable)
|
||||
{
|
||||
ValueType[Enum.len] values;
|
||||
ValueType[Enum.values.len] values;
|
||||
}
|
||||
|
||||
fn void EnumMap.init(&self, ValueType init_value)
|
||||
|
||||
@@ -8,9 +8,10 @@
|
||||
module std::collections::enumset{Enum};
|
||||
import std::io;
|
||||
|
||||
alias EnumSetType @private = $typefrom(type_for_enum_elements(Enum.elements));
|
||||
const ENUM_COUNT @private = Enum.values.len;
|
||||
alias EnumSetType @private = $typefrom(type_for_enum_elements(ENUM_COUNT));
|
||||
|
||||
const IS_CHAR_ARRAY = Enum.elements > 128;
|
||||
const IS_CHAR_ARRAY = ENUM_COUNT > 128;
|
||||
typedef EnumSet (Printable) = EnumSetType;
|
||||
|
||||
fn void EnumSet.add(&self, Enum v)
|
||||
|
||||
@@ -24,11 +24,9 @@ struct SliceRaw
|
||||
|
||||
macro @enum_lookup($Type, #value, value)
|
||||
{
|
||||
var $elements = $Type.elements;
|
||||
$for var $i = 0; $i < $elements; $i++:
|
||||
var $val = $Type.from_ordinal($i);
|
||||
$foreach $val : $Type.values:
|
||||
if ($val.#value == value) return $val;
|
||||
$endfor
|
||||
$endforeach
|
||||
return NOT_FOUND?;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user