-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
37 additions
and
87 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,23 @@ | ||
import { ZrEnumItem } from "@rbxts/zirconium/out/Data/Enum"; | ||
import { ZrObjectUserdata } from "@rbxts/zirconium/out/Data/Userdata"; | ||
import { ZirconEnum, EnumMatchTree } from "./ZirconEnum"; | ||
|
||
/** | ||
* High level enum item wrapper for Zircon | ||
* An extension of the `ZrEnumItem` class for Zircon. | ||
*/ | ||
|
||
export class ZirconEnumItem< | ||
TParent extends ZirconEnum<string> = ZirconEnum<string>, | ||
K extends string = string | ||
> extends ZrObjectUserdata<K> { | ||
public constructor(private enumParent: TParent, private id: number, private name: K) { | ||
super(name); | ||
} | ||
|
||
/** | ||
* Gets the numeric value of this enum | ||
* @returns The numeric value | ||
*/ | ||
public GetId() { | ||
return this.id; | ||
} | ||
|
||
/** | ||
* Gets the string literal value of this enum | ||
* @returns The value | ||
*/ | ||
public GetName() { | ||
return this.name; | ||
} | ||
|
||
/** | ||
* Gets the Enum of this EnumItem | ||
* @returns The Enum | ||
*/ | ||
public GetEnumType() { | ||
return this.enumParent as TParent; | ||
> extends ZrEnumItem { | ||
public constructor(private enumParent: TParent, id: number, name: K) { | ||
super(enumParent, id, name); | ||
} | ||
|
||
/** | ||
* Performs a match against this enum value - similar to `match` in Rust. | ||
* @param matches The matches to check against | ||
*/ | ||
public Match<R>(matches: EnumMatchTree<TParent, K, R>) { | ||
return matches[this.GetName()](this); | ||
} | ||
|
||
public toString() { | ||
return tostring(this.enumParent) + "::[EnumItem '" + this.name + "']"; | ||
public match<R>(matches: EnumMatchTree<TParent, K, R>) { | ||
return matches[this.getName() as K](this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters