Repository navigation
Free Function Stereotypes
A free function is a function that is not bound to a particular class. Static methods/functions as well as friend functions (C++) are also considered as free functions.
| Type | Description |
|---|---|
| predicate | Returns a bool derived from the parameters |
| property | Returns a non-bool derived from the parameters |
| global-command | Changes a global or a static variable, by a write or by a call on the variable other than a query method |
| command | Changes a parameter that shares its object with the caller, by a write through the parameter or by a call on the parameter other than a query method |
| factory | Creates an object with new, std::make_unique, or std::make_shared and returns the object |
| main | A main function, such as main, Main, wmain, WinMain, wWinMain, _tmain, or _tWinMain |
| literal | Does not read or change parameters, globals, or static variables |
| wrapper | Does not change a parameter that shares its object with the caller. Has at least one call to methods of other types or to a free function |
| empty | Has no statements |
| unclassified | Fits none of the rules |
TABLE 1. Taxonomy of Free Function Stereotypes.
Stereocode labels free functions and static methods only with the option -f. A main function and an empty function get no other stereotype, while a function can carry several of the other stereotypes, such as predicate wrapper.
A returned value is derived from the parameters when the function uses a parameter and a return expression returns a parameter or computes a value, such as return a < b; or return found;.
A parameter shares its object with the caller when it is a C++ reference, pointer, or array to an object that is not const, a C# ref or out parameter or a parameter of a non-primitive type, or a Java parameter of a non-primitive type. The query methods and the ignored calls of the method stereotypes hold for free functions as well.