About
The MAXON API makes heavy use of C++ preprocessor macros. These macros are used to automatically create code or to mark parts of the code (e.g. in interfaces). The macros described on this page are relevant for every kind of development. Other specialised macros exist for special tasks.
Object Use
Under Xcode / GCC the compiler can check if the return value of a function is used or not. If a return value that should be used is not used, a compile error is thrown.
- Note
- Do not use these macros to mute errors returned with the error system. Instead use iferr_cannot_fail() or iferr_ignore(). See Error Handling.
bool Bool
boolean type, possible values are only false/true, 8 bit
Definition: apibase.h:181
#define MAXON_WARN_UNUSED
Definition: compilerdetection.h:291
CriticalFunction();
Py_UCS4 * res
Definition: unicodeobject.h:1113
#define MAXON_WARN_MUTE_UNUSED
The MAXON_WARN_MUTE_UNUSED macro is deprecated. Please use iferr_ignore or iferr_cannot_fail and spec...
Definition: compilerdetection.h:295
- MAXON_WARN_UNUSED_CLASS: If a class marked with this macro is used as a return value but this return value is not used, an error is thrown.
{
};
static CriticalInfo GetCriticalInfo();
int32_t Int32
32 bit signed integer datatype.
Definition: apibase.h:176
#define MAXON_WARN_UNUSED_CLASS
Definition: compilerdetection.h:292
GetCriticalInfo();
const CriticalInfo
info = GetCriticalInfo();
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
_Py_clock_info_t * info
Definition: pytime.h:197
If a variable is declared but not used this will trigger a compile warning. This warning can be suppressed with this function:
- maxon::UseVariable(): Uses the given variable.
- Note
- Using maxon::UseVariable() will not cause any performance penalty.
{
}
{
maxon::UseVariable(number);
}
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:188
#define MAXON_SCOPE
Definition: apibase.h:2841
Program Flow and Structure
These macros are used to mark certain parts of the source code:
- MAXON_SCOPE: Marks a block of code that is scoped for a certain reason.
- MAXON_UNLIKELY: Marks an unlikely branch for branch prediction.
- MAXON_LIKELY: Marks a likely branch for branch prediction.
{
number++;
}
{
number++;
}
PyObject * key
Definition: abstract.h:289
#define iferr_return
Definition: resultbase.h:1519
{
number = 100;
}
#define MAXON_UNLIKELY(...)
Definition: compilerdetection.h:404
Switch-case statements can be improved with:
enum class MyEnum
{
};
{
break;
break;
default:
break;
}
PyObject * value
Definition: abstract.h:715
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:210
#define MAXON_SWITCH_CHECKALLENUMS_BEGIN
Definition: compilerdetection.h:361
#define MAXON_SWITCH_CHECKALLENUMS_END
Definition: compilerdetection.h:362
A
Quality A.
Definition: macros.h:1
B
Quality B.
Definition: macros.h:2
Finally
The code defined in a "finally" block is executed when the program flow leaves the current scope.
- finally: Defines a code block which is executed when the scope is left.
- finally_once: Returns a maxon::FinallyOnce object that can be used to disable the code block execution.
{
{
};
}
#define NewMemClear(T, cnt)
Definition: defaultallocator.h:204
#define finally
Definition: finally.h:64
char Char
signed 8 bit character
Definition: apibase.h:184
return OK
Definition: apibase.h:2690
void DeleteMem(T *&p)
Definition: defaultallocator.h:257
#define iferr_scope
Definition: resultbase.h:1384
Enummerations
{
{
#define MAXON_ENUM_LIST(E,...)
Definition: enumflags.h:137
#define MAXON_ENUM_FLAGS(E,...)
Definition: enumflags.h:192
QUALITY
Various qualities.
Definition: macros.h:23
PRIMARY_COLOR
[macros_enums_declare]
Definition: macros.h:13
Classes and Functions
The following macros are used to declare classes and their functions:
These macros are used to implement certain operators automatically:
class NumberClass
{
public:
{
}
{
return &_number;
}
{
}
private:
};
PyObject PyObject * v
Definition: abstract.h:297
PyObject * src
Definition: abstract.h:305
#define MAXON_IMPLICIT
Definition: apibase.h:172
#define MAXON_OPERATOR_EQUALITY_HASHCODE(T,...)
Definition: classhelpers.h:563
#define MAXON_NONCONST_COUNTERPART(...)
Definition: classhelpers.h:625
#define MAXON_COPY_MEMBERS(...)
Definition: classhelpers.h:471
#define MAXON_OPERATOR_COPY_ASSIGNMENT(TypeName)
Definition: classhelpers.h:386
NumberClass someNumber(1);
maxon::Int*
const number = someNumber.GetNumber();
*number = *number + 1;
NumberClass someOtherNumber(0);
someOtherNumber = someNumber;
PyObject Py_hash_t hash
Definition: dictobject.h:35
UInt64 UInt
unsigned 32/64 bit int, size depends on the platform
Definition: apibase.h:189
Utility
Other utility macros exist:
Py_ssize_t i
Definition: abstract.h:645
Definition: string.h:1235
PyFrameObject * f
Definition: ceval.h:26
Float64 Float
Definition: apibase.h:197
#define MAXON_HASHCODE(...)
MAXON_HASHCODE computes the hash code of the arguments based on DefaultCompare::GetCombinedHashCode.
Definition: classhelpers.h:481
Further Reading