Skip to content

Macros#

Writing platform dependent code#

AUI provides a set of AUI_PLATFORM_* and AUI_COMPILER_* definitions for platform and compiler checking to use in both CMake and C++.

Platform checks#

Platform C++ CMake Platform specific dir(s)
[Windows (operating system)](windows.md)
 #if AUI_PLATFORM_WIN
   // ...
 #endif
 if(AUI_PLATFORM_WIN)
   # ...
 endif()
src/Platform/win32 src/platform/win32
[Linux (-based desktop OSes)](linux.md)
 #if AUI_PLATFORM_LINUX
   // ...
 #endif
 if(AUI_PLATFORM_LINUX)
   # ...
 endif()
src/Platform/linux src/platform/linux
[macOS (operating system)](macos.md)
 #if AUI_PLATFORM_MACOS
   // ...
 #endif
 if(AUI_PLATFORM_MACOS)
   # ...
 endif()
src/Platform/macos src/platform/macos
[Android (operating system)](android.md)
 #if AUI_PLATFORM_ANDROID
   // ...
 #endif
 if(AUI_PLATFORM_ANDROID)
   # ...
 endif()
src/Platform/android src/platform/android
[iOS (operating system)](ios.md) (both iPhone and iPad)
 #if AUI_PLATFORM_IOS
   // ...
 #endif
 if(AUI_PLATFORM_IOS)
   # ...
 endif()
src/Platform/ios src/platform/ios
Apple([macOS](macos.md), [iOS](ios.md))
 #if AUI_PLATFORM_APPLE
   // ...
 #endif
 if(AUI_PLATFORM_APPLE)
   # ...
 endif()
src/Platform/apple src/platform/apple
Unix([Linux](linux.md), [Android](android.md), [macOS](macos.md), [iOS](ios.md))
 #if AUI_PLATFORM_UNIX
   // ...
 #endif
 if(AUI_PLATFORM_UNIX)
   # ...
 endif()
src/Platform/unix src/platform/unix
[Emscripten (WebAssembly)](emscripten.md)
 #if AUI_PLATFORM_EMSCRIPTEN
   // ...
 #endif
 if(AUI_PLATFORM_EMSCRIPTEN)
   # ...
 endif()
src/Platform/emscripten src/platform/emscripten

Platform specific sources#

With AUI, the platform dependent code can be placed in src/Platform/<PLATFORM_NAME> or src/platform/<PLATFORM_NAME> dirs, where <PLATFORM_NAME> is one of the supported platforms (see the table above).

Note

Both cases (Platform and platform) were added to honor projects with various directory naming agreements.

Compiler checks#

Compiler C++ CMake
MSVC
 #if AUI_COMPILER_MSVC
   // ...
 #endif
 if(AUI_COMPILER_MSVC)
   # ...
 endif()
GCC (including MinGW)
 #if AUI_COMPILER_GCC
   // ...
 #endif
 if(AUI_COMPILER_GCC)
   # ...
 endif()
CLANG
 #if AUI_COMPILER_CLANG
   // ...
 #endif
 if(AUI_COMPILER_CLANG)
   # ...
 endif()

Other#

AUI_MODULE_NAME

Target name exposed by aui_module and aui_executable.


AUI_CMAKE_PROJECT_VERSION

${CMAKE_PROJECT_VERSION} exposed by aui_module and aui_executable.

CMAKE_PROJECT_VERSION is typically defined by project CMake command:

project(test_project VERSION 2.2.8)

API_\<module name\>

dllexport (on Windows) or visibility (on other platforms) policy for the symbol.

class API_AUI_VIEWS AView ... { // defined in aui.views module
  ...
};

AJSON_FIELDS

Json fields definition.


AJSON_FIELDS_ENTRY

Json entry of the same C++ and JSON field name.


AUI_ASSERT

Asserts that the passed condition evaluates to true.


AUI_ASSERTX

Asserts that the passed condition evaluates to true. Adds extra message string.


AUI_ASSERT_NO_CONDITION

Always triggers assertion fail.


AUI_ASSERT_UI_THREAD_ONLY

Asserts that the macro invocation has been performed in the UI thread.


AUI_ASSERT_WORKER_THREAD_ONLY

Asserts that the macro invocation has not been performed in the UI thread.


AUI_BREAKPOINT

Stops program execution in attached debugger as if a breakpoint were set.


AUI_DECLARATIVE_FOR

ranged-for-loop style wrapped for AForEachUI.


AUI_DEFER

Defers execution of the next block to the end of current block (RAII scope).


AUI_DO_ONCE

Executes following function call or {} block once per program execution


AUI_EMIT_FOREIGN

emits the specified signal in context of specified object.


AUI_EMIT_FOREIGN_SIGNAL

Emits a signal of a foreign object.


AUI_ENTRY

Application entry point.


AUI_ENUM_FLAG

Make a bitfield-style enum class.


AUI_ENUM_VALUES

Defines all enum values for AEnumerate.


AUI_JNI_CLASS

Defines getClassName and other useful methods required for Java class definition.


AUI_JNI_METHOD

Defines nonstatic method C++ -> Java.


AUI_JNI_STATIC_METHOD

Defines static method C++ -> Java.


AUI_LET

Performs multiple operations on a single object without repeating its name (in place) This function can be used as an operator on object.


AUI_MARK_AS_USED

Marks the variable as being used.


AUI_NO_OPTIMIZE_OUT

Forbids object from being optimized out by compiler.


AUI_PERFORM_AS_MEMBER

Performs multiple operations on a single object without repeating its name.


AUI_PP_CAT

Expands and concatenates the arguments. Constructed macros reevaluate.


AUI_PP_COMMA

Returns a comma. Given a variadic number of arguments.


AUI_PP_COMMA_IF

Returns comma if _i != 0. Requires _i to be between 0 and 15.


AUI_PP_EMPTY

Returns empty. Given a variadic number of arguments.


AUI_PP_FOR_EACH

Expands to _Macro(0, _Data, e1) _Macro(1, _Data, e2) ... _Macro(K -1, _Data, eK) as many of AUI_INTERNAL_NARG0 _Tuple.


AUI_PP_GENERIC_IF

Similar to AUI_PP_IF but takes _Then and _Else in parentheses.


AUI_PP_HAS_COMMA

Returns 1 if the expansion of arguments has an unprotected comma.Otherwise returns 0.


AUI_PP_HEAD

Returns the first argument.


AUI_PP_IDENTITY

Returns the only argument.


AUI_PP_IF

Evaluates to _Then if _Cond is 1 and _Else if _Cond is 0.


AUI_PP_INC

Increments the argument, requires the argument to be between 0 and 15.


AUI_PP_IS_BEGIN_PARENS

Expands to 1 if the first argument starts with something in parentheses, otherwise to 0.


AUI_PP_IS_EMPTY

If the arguments after expansion have no tokens, evaluates to 1. Otherwise evaluates to 0.


AUI_PP_IS_ENCLOSED_PARENS

Expands to 1 is there is only one argument and it is enclosed in parentheses.


AUI_PP_NARG

Evaluates to the number of arguments after expansion.


AUI_PP_NARG0

Evaluates to the number of arguments after expansion. Identifies 'empty' as 0.


AUI_PP_REMOVE_PARENS

Remove the parens, requires AUI_PP_IS_ENCLOSED_PARENS(args) => 1.


AUI_PP_REPEAT

Expands to _Macro(0, _Data, ) _Macro(1, _Data, ) ... _Macro(K - 1, _Data, )


AUI_PP_STRINGIZE

Expands and stringifies the only argument.


AUI_PP_TAIL

Returns the tail. A variadic list of all arguments minus the first


AUI_PP_VARIADIC_CALL

Calls CAT(_Macro, NARG(VA_ARGS))(VA_ARGS)


AUI_SLOT

Passes some variable and type of the variable separated by comma. It's convenient to use with the connect function (see examples).


AUI_THREADPOOL

Executes following {} block asynchronously in the global thread pool. Unlike AUI_THREADPOOL_X, does now allow to set lambda's capture. Lambda's capture is [=].


AUI_THREADPOOL_X

Executes following {} block asynchronously in the global thread pool. Unlike AUI_THREADPOOL, allows to set lambda's capture but you should always specify lambda's capture.


AUI_UI_THREAD

Executes lambda on main thread.


AUI_UI_THREAD_X

Executes lambda on main thread. Allows to determine lambda's capture.


AUI_WITH_STYLE

Allows to define a style to the view right in place.


emit

emits the specified signal in context of this object.


me

Passes the current class and type of the current class separated by comma. It's convenient to use with the connect function:


signals

A signal declaration.