Flutter Engine
embedder_safe_access.h File Reference
#include <type_traits>

Go to the source code of this file.

Macros

#define SAFE_ACCESS(pointer, member, default_value)
 
#define SAFE_EXISTS(pointer, member)   (SAFE_ACCESS(pointer, member, nullptr) != nullptr)
 Checks if the member exists. 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. More...
 

Macro Definition Documentation

◆ SAFE_ACCESS

#define SAFE_ACCESS (   pointer,
  member,
  default_value 
)
Value:
([=]() { \
if (offsetof(std::remove_pointer<decltype(pointer)>::type, member) + \
sizeof(pointer->member) <= \
pointer->struct_size) { \
return pointer->member; \
} \
return static_cast<decltype(pointer->member)>((default_value)); \
})()

Definition at line 10 of file embedder_safe_access.h.

Referenced by flutter::CreateEmbedderTaskRunner(), FlutterEngineInitialize(), FlutterEnginePostDartObject(), FlutterEngineSendPlatformMessage(), FlutterEngineSendPointerEvent(), FlutterEngineSendWindowMetricsEvent(), FlutterEngineUpdateLocales(), InferExternalViewEmbedderFromArgs(), InferOpenGLPlatformViewCreationCallback(), IsSoftwareRendererConfigValid(), and PopulateSnapshotMappingCallbacks().

◆ SAFE_EXISTS

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

Checks if the member exists.

Definition at line 21 of file embedder_safe_access.h.

Referenced by IsOpenGLRendererConfigValid().

◆ 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.

Definition at line 25 of file embedder_safe_access.h.

Referenced by IsOpenGLRendererConfigValid().