实现基础断言 添加 Release 构建版本
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "Misc/AssertionMacros.h"
|
||||
|
@ -9,6 +9,40 @@
|
||||
|
||||
NS_REDCRAFT_BEGIN
|
||||
|
||||
// Build information macro.
|
||||
|
||||
#ifndef PLATFORM_NAME
|
||||
#define PLATFORM_NAME Unknown
|
||||
#endif
|
||||
|
||||
#ifndef PLATFORM_WINDOWS
|
||||
#define PLATFORM_WINDOWS 0
|
||||
#endif
|
||||
|
||||
#ifndef PLATFORM_LINUX
|
||||
#define PLATFORM_LINUX 0
|
||||
#endif
|
||||
|
||||
#ifndef PLATFORM_UNKNOWN
|
||||
#define PLATFORM_UNKNOWN 0
|
||||
#endif
|
||||
|
||||
#ifndef BUILD_TYPE
|
||||
#define BUILD_TYPE Unknown
|
||||
#endif
|
||||
|
||||
#ifndef BUILD_DEBUG
|
||||
#define BUILD_DEBUG 0
|
||||
#endif
|
||||
|
||||
#ifndef BUILD_RELEASE
|
||||
#define BUILD_RELEASE 0
|
||||
#endif
|
||||
|
||||
#ifndef BUILD_UNKNOWN
|
||||
#define BUILD_UNKNOWN 0
|
||||
#endif
|
||||
|
||||
// Function type macros.
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
|
52
Redcraft.Core/Source/Public/Misc/AssertionMacros.h
Normal file
52
Redcraft.Core/Source/Public/Misc/AssertionMacros.h
Normal file
@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreTypes.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
NS_REDCRAFT_BEGIN
|
||||
|
||||
NS_PRIVATE_BEGIN
|
||||
|
||||
class FRecursionScopeMarker
|
||||
{
|
||||
public:
|
||||
|
||||
FRecursionScopeMarker(uint8& InCounter) : Counter(InCounter) { ++Counter; }
|
||||
~FRecursionScopeMarker() { --Counter; }
|
||||
|
||||
private:
|
||||
|
||||
uint8& Counter;
|
||||
|
||||
};
|
||||
|
||||
NS_PRIVATE_END
|
||||
|
||||
#if BUILD_DEBUG
|
||||
|
||||
#define check_code(InCode) do { InCode; } while (false)
|
||||
#define check(InExpr) assert(InExpr)
|
||||
#define checkf(InExpr, InFormat, ...) assert(InExpr)
|
||||
#define check_no_entry() checkf(false, "Enclosing block should never be called.")
|
||||
#define check_no_reentry() { static bool bBeenHere##__LINE__ = false; checkf(!bBeenHere##__LINE__, "Enclosing block was called more than once."); bBeenHere##__LINE__ = true; }
|
||||
#define check_no_recursion() static uint8 RecursionCounter##__LINE__ = 0; checkf(RecursionCounter##__LINE__ == 0, "Enclosing block was entered recursively."); const NS_PRIVATE::FRecursionScopeMarker ScopeMarker##__LINE__(RecursionCounter##__LINE__)
|
||||
#define verify(InExpr) assert(InExpr)
|
||||
#define verifyf(InExpr, InFormat, ...) assert(InExpr)
|
||||
#define unimplemented() check(false, "Unimplemented function called.")
|
||||
|
||||
#else
|
||||
|
||||
#define check_code(...)
|
||||
#define check(InExpr)
|
||||
#define checkf(InExpr, InFormat, ...)
|
||||
#define check_no_entry()
|
||||
#define check_no_reentry()
|
||||
#define check_no_recursion()
|
||||
#define verify(InExpr) { if(InExpr) { } }
|
||||
#define verifyf(InExpr, InFormat, ...) { if(InExpr) { } }
|
||||
#define unimplemented()
|
||||
|
||||
#endif
|
||||
|
||||
NS_REDCRAFT_END
|
Reference in New Issue
Block a user