-
Notifications
You must be signed in to change notification settings - Fork 62
Contributing
chrisd1100 edited this page Apr 9, 2023
·
3 revisions
libmatoya is set up in a tree-like fashion where code in common with all platforms is at the root of /src. From there, as you go further up the tree towards the leaves, the code becomes more platform specific. A major development goal is to move as much code as possible towards the root and maintain as little as possible towards the leaves. libmatoya will never #ifdef based on platform, instead it uses the makefile to choose different paths through the tree.
- There are two types of functions:
utilityandmethod.methodfunctions essentially mimic the semantics of aclassin an object oriented language:- There is always a constructor called
MTY_ObjectCreatethat returns a pointer to the new object. - There is always a destructor called
MTY_ObjectDestroythat takes the object by reference, disposes of everything it can associated with the object, callsMTY_Freeon the object itself, and sets it toNULL. - Methods appear as
MTY_ObjectXXX, the method name in this case beingXXX. Methods take the object as their first argument labeledctx.
- There is always a constructor called
- Modules in
matoya.hare ordered first by dependence, second alphabetically. -
methodfunctions are always grouped together, with the constructor and destructor appearing first in the group. - There is no strict function ordering rule beyond this, however functions that will likely be called together or should be called in succession should be ordered as such.
- Public function implementations should be ordered in the same order they appear in the header, and with the same parameter names. There is no rule for static or private symbols.
- Function naming convention:
MTY_[Object|Module]VerbNoun- If a
methodfunction, the object name always comes first. - Although rare, functions may be namespaced by their module name to differentiate between other
libmatoyanames, i.e.MTY_CryptoHash. - Nouns are optional if the verb and function signature is clear enough.
- Exception: Conversion functions in the form of
MTY_XToY - Exception: Canonical algorithms or C standard library functions, such as
MTY_CRC32orMTY_SprintfD - Exception: Because "Exists" checks are common, shorthand
MTY_XExistsrather thanMTY_DoesXExist.
- If a
- Enumeration naming convention:
MTY_Noun- Each value in the
enumshould be named in accordance with the type name, i.e.MTY_ColorFormatwould have valuesMTY_COLOR_FORMAT_BGRAandMTY_COLOR_FORMAT_NV12. - In the case of generic qualifiers, like the words
Type,Mode, andState, that word can optionally be dropped from the value names if they don't lose clarity, i.e.MTY_EventTypewith valuesMTY_EVENT_KEYandMTY_EVENT_BUTTON.
- Each value in the