Add README.md
This commit is contained in:
parent
bdd292ce2a
commit
44b6e4c222
1 changed files with 25 additions and 0 deletions
25
README.md
Normal file
25
README.md
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Generate reflection code for GML enums
|
||||||
|
Check out this article for why you might want to do this: https://synthasmagoria.github.io/error_handling_in_gm/
|
||||||
|
|
||||||
|
The program generates a few functions that make it possible to retreive the names of enums and enum members.
|
||||||
|
To tell the program to generate reflection for a specific enum add `gml_pragma("enum_reflection")` on the line before.
|
||||||
|
```ts
|
||||||
|
/* This file was generated using enum_reflection tool */
|
||||||
|
enum Enum { CoolError, _Count }
|
||||||
|
global._ENUM_NAMES = [ "CoolError", ];
|
||||||
|
global._ENUM_MEMBER_NAMES = [
|
||||||
|
["Bad", "Bad2", "Bad3"],
|
||||||
|
];
|
||||||
|
function enum_get_name(index) {
|
||||||
|
return global._ENUM_NAMES[index];
|
||||||
|
}
|
||||||
|
function enum_get_member_name(index, member) {
|
||||||
|
return global._ENUM_MEMBER_NAMES[index][member];
|
||||||
|
}
|
||||||
|
function enum_get_member_names(index) {
|
||||||
|
return global._ENUM_MEMBER_NAMES[index];
|
||||||
|
}
|
||||||
|
function enum_get_member_name_full(index, member) {
|
||||||
|
return $"{global._ENUM_NAMES[index]}.{global._ENUM_MEMBER_NAMES[index][member]}";
|
||||||
|
}
|
||||||
|
```
|
||||||
Loading…
Add table
Add a link
Reference in a new issue