Flutter Engine
The Flutter Engine
Macros
embedder_struct_macros.h File Reference
#include <type_traits>

Go to the source code of this file.

Macros

#define STRUCT_HAS_MEMBER(pointer, member)
 
#define SAFE_ACCESS(pointer, member, default_value)
 
#define SAFE_EXISTS(pointer, member)    (SAFE_ACCESS(pointer, member, nullptr) != nullptr)
 Checks if the member exists and is non-null. More...
 
#define SAFE_EXISTS_ONE_OF(pointer, member1, member2)    (SAFE_EXISTS(pointer, member1) != SAFE_EXISTS(pointer, member2))
 Checks if exactly one of member1 or member2 exists and is non-null. More...
 

Macro Definition Documentation

◆ SAFE_ACCESS

#define SAFE_ACCESS (   pointer,
  member,
  default_value 
)
Value:
([=]() { \
if (STRUCT_HAS_MEMBER(pointer, member)) { \
return pointer->member; \
} \
return static_cast<decltype(pointer->member)>((default_value)); \
})()
#define STRUCT_HAS_MEMBER(pointer, member)

Definition at line 16 of file embedder_struct_macros.h.

◆ SAFE_EXISTS

#define SAFE_EXISTS (   pointer,
  member 
)     (SAFE_ACCESS(pointer, member, nullptr) != nullptr)

Checks if the member exists and is non-null.

Definition at line 25 of file embedder_struct_macros.h.

◆ SAFE_EXISTS_ONE_OF

#define SAFE_EXISTS_ONE_OF (   pointer,
  member1,
  member2 
)     (SAFE_EXISTS(pointer, member1) != SAFE_EXISTS(pointer, member2))

Checks if exactly one of member1 or member2 exists and is non-null.

Definition at line 29 of file embedder_struct_macros.h.

◆ STRUCT_HAS_MEMBER

#define STRUCT_HAS_MEMBER (   pointer,
  member 
)
Value:
((offsetof(std::remove_pointer<decltype(pointer)>::type, member) + \
sizeof(pointer->member) <= \
pointer->struct_size))
GLenum type

Definition at line 11 of file embedder_struct_macros.h.