You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In most cases of DM, flags are implemented using defines. This is fine, however it can be hard to tell if a flag is being used correctly or not.
This feature requests requests for any method to be able to limit the usage of specific defines down to certain usecases, however it is implemented.
This is particularly tricky to define a nice example of, since this needs to catch the names of defines before they are sent through to the preprocessor, so I'm not exactly sure how this would look.
Potential option 1: Limit the usage to specific variables, by having something before the define
// Rejects any uses that aren't in a variable called "flags"DEFINE_USAGE(flags)
#defineEXAMPLE (1<<0)
DEFINE_USAGE(flags)
#defineTESTXAMPLE (1<<1)
/datum/test
// Acceptedvar/flags=EXAMPLE//! Error: EXAMPLE cannot be used in flags1var/flags1=EXAMPLE/datum/other
// Acceptedvar/flags=EXAMPLE
Potential option 2: Introduce enum types, by having something before the define
// Also would be nice to allow this for syntax too// Anything with a define type would be rejected if you attempt to store it in a variable that doesn't have an ACCEPT_TYPE for that type.DEFINE_TYPE(basic_flags) #define EXAMPLE (1<<0)
DEFINE_TYPE(basic_flags) #define TESTXAMPLE (1<<1)
/datum// AcceptedACCEPT_TYPE(basic_flags)
var/flags=EXAMPLE// AcceptedACCEPT_TYPE(basic_flags)
var/flags1=EXAMPLE//! Error, attempting to use define in a variable that doesn't explicitly accept that definition.var/other=TESTXAMPLE
In the above cases, the DM implementation of these defines is just a noop.
The text was updated successfully, but these errors were encountered:
In most cases of DM, flags are implemented using defines. This is fine, however it can be hard to tell if a flag is being used correctly or not.
This feature requests requests for any method to be able to limit the usage of specific defines down to certain usecases, however it is implemented.
This is particularly tricky to define a nice example of, since this needs to catch the names of defines before they are sent through to the preprocessor, so I'm not exactly sure how this would look.
Potential option 1: Limit the usage to specific variables, by having something before the define
Potential option 2: Introduce enum types, by having something before the define
In the above cases, the DM implementation of these defines is just a noop.
The text was updated successfully, but these errors were encountered: