Files
ZandarioandGitHub 8eed21e1cf Singletons and abstract_types! (#4760)
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
I finally have the pleasure of killing decl by giving it a new name and
updated handling.
Also abstract_types now have universal support!

Based on:
Baystation12/Baystation12/pull/32114
Baystation12/Baystation12/pull/32687

## Changelog
🆑
code: /decl/ is now /singleton/
code: abstract_type is now on the /datum/ level
/🆑

<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
2022-11-27 23:24:30 -08:00

24 lines
1.3 KiB
Plaintext

/*
* Performance behaviors for avoiding calling procs unecessarily on the Singletons global.
*/
/// Get a singleton instance according to path P. Creates it if necessary. Null if abstract or not a singleton.
#define GET_SINGLETON(P)\
(ispath(P, /singleton) ? (Singletons.resolved_instances[P] ? Singletons.instances[P] : Singletons.GetInstance(P)) : null)
/// Get a (path = instance) map of valid singletons according to typesof(P).
#define GET_SINGLETON_TYPE_MAP(P)\
(ispath(P, /singleton) ? (Singletons.resolved_type_maps[P] ? Singletons.type_maps[P] : Singletons.GetTypeMap(P)) : list())
/// Get a (path = instance) map of valid singletons according to subtypesof(P).
#define GET_SINGLETON_SUBTYPE_MAP(P)\
(ispath(P, /singleton) ? (Singletons.resolved_subtype_maps[P] ? Singletons.subtype_maps[P] : Singletons.GetSubtypeMap(P)) : list())
/// Get a list of valid singletons according to typesof(path).
#define GET_SINGLETON_TYPE_LIST(P)\
(ispath(P, /singleton) ? (Singletons.resolved_type_lists[P] ? Singletons.type_lists[P] : Singletons.GetTypeList(P)) : list())
/// Get a list of valid singletons according to subtypesof(path).
#define GET_SINGLETON_SUBTYPE_LIST(P)\
(ispath(P, /singleton) ? (Singletons.resolved_subtype_lists[P] ? Singletons.subtype_lists[P] : Singletons.GetSubtypeList(P)) : list())