This commit is contained in:
Dante
2026-05-21 23:40:20 -07:00
parent 3e2915dff7
commit 877a69d844
5737 changed files with 29796 additions and 1589684 deletions

View File

@ -40,6 +40,14 @@ abstract EnumFlags<T:EnumValue>(Int) {
this = i;
}
@:from static function from<T:EnumValue>(e:T) : EnumFlags<T> {
return new EnumFlags(1 << e.getIndex());
}
@:op(a|b) function or(f:haxe.EnumFlags<T>) : haxe.EnumFlags<T>;
@:op(a&b) function and(f:haxe.EnumFlags<T>) : haxe.EnumFlags<T>;
@:op(a^b) function xor(f:haxe.EnumFlags<T>) : haxe.EnumFlags<T>;
/**
Checks if the index of enum instance `v` is set.
@ -76,6 +84,22 @@ abstract EnumFlags<T:EnumValue>(Int) {
this &= 0xFFFFFFFF - (1 << Type.enumIndex(v));
}
/**
Depending on the value of `condition` sets (`condition=true`) or unsets (`condition=false`)
the index of enum instance `v`.
This method is optimized if `v` is an enum instance expression such as
`SomeEnum.SomeCtor`.
If `v` is `null`, the result is unspecified.
**/
public inline function setTo(v:T, condition:Bool):Void {
if(condition)
set(v)
else
unset(v);
}
/**
Convert a integer bitflag into a typed one (this is a no-op, it does not
have any impact on speed).