Basic Rules for Naming Functions and Variables

Categories

TWL-SDK functions can be grouped into categories according to their purpose. They have been given names that help make these categories clear.

Categories
A category is indicated with two or more uppercase letters. (Numerals can also be used starting in the second position, but only for items related to graphics.)
Syntax: [A-Z][A-Z0-9]+
OS Items related to the operating system.
G2,G3,GX... Items related to graphics. (Numerals are also included.)
MI Items related to memory exchange, such as DMA.
SVC Items related to system calls.

(03/11/13)

Note: The distinction in the main processor and subprocessor categories was eliminated. Uppercase letters are used uniformly and consistently.

(04/01/18)

Functions

Functions are named as follows: Subject and object are connected without an underscore. The first letter of each separate word is capitalized.

Public functions
[Category name]_[verb] [object, and so on]
Examples: OS_SetInterruptMask, OS_IsLocked
Private functions
[Category name]i_[verb] [object, etc]
Example: OSi_SetInterruptMaskBase
Static functions
Free form

However, there are some functions that do not follow these rules, such as OS_InterruptHandler.

(03/11/13)

There are two different names that can be given to a function that generates or initializes objects: Create or Init. Create is used when a function must later be called to explicitly destroy the object. Init is used when when the object does not need to be destroyed.

(03/12/15)

Variable Type Name

Functions and types are the same since the name used in typedefs fundamentally adhere to Nintendo GameCube conventions. Note that a verb is not used after the category name.

Variable type name
[Category name] [noun]
Example: OSInterruptCallback
Variable name exceptions
[Category name] [verb] Mode
Example: OSCopyMode

As an exception, names such as OSCopyMode are given to functions used to control the operations of the API itself. This particular function, for example, is likely to control the operation of a function with a name like GXCopy. Names such as GXCopyStatus and GXCopyType are other possibilities. Although this is recognized as a natural way to name such functions, do not take this concept too far.

(03/11/13)

Enumerator Names and Macro Names

Constants defined by enum, define, and const have the format shown below.

Constant Name
[Category name] _ [A-Z0-9_]+
Examples: OS_INTERRUPT_MAX, OS_INTERRUPT_MAX

(04/01/18)


TWL-06-0011-001-B
CONFIDENTIAL