Karma Engine
Loading...
Searching...
No Matches
Core.h
1#pragma once
2
3#ifdef KR_DYNAMIC_LINK
4#ifdef KR_WINDOWS_PLATFORM
5 #ifdef KR_BUILD_DLL
6 #define KARMA_API __declspec(dllexport)
7 #else
8 #define KARMA_API __declspec(dllimport)
9 #endif
10#elif defined KR_LINUX_PLATFORM
11 #ifdef KR_BUILD_SO
12 #define KARMA_API __attribute__((visibility("default")))
13 #else
14 #define KARMA_API
15 #endif
16#elif defined KR_MAC_PLATFORM
17 #ifdef KR_BUILD_SO
18 #define KARMA_API __attribute__((visibility("default")))
19 #else
20 #define KARMA_API
21 #endif
22#else
23#error Unsupported Platform detected!
24#endif
25#else
26#define KARMA_API
27#endif
28
29#define BIT(x) (1 << x)
30
31// Assertions
32#ifdef KR_ENABLE_ASSERTS
33#include "Karma/Log.h"
34 #if _MSC_VER
35 #include <intrin.h>
36 #define debugBreak() __debugbreak()
37 #else
38 #include <signal.h>
39 #define debugBreak() raise(SIGTRAP)
40 #endif
41
42 #define KR_ASSERT(expr, ...) \
43 if(expr){} \
44 else \
45 {\
46 KR_ERROR("Assertion Failed: {0}. Refer file: {1}, line: {2}", __VA_ARGS__, __FILE__, __LINE__); \
47 debugBreak(); \
48 }
49 #define KR_CORE_ASSERT(expr, ...) \
50 if(expr){} \
51 else \
52 {\
53 KR_CORE_ERROR("Assertion Failed: {0}. Refer file: {1}, line: {2}", __VA_ARGS__, __FILE__, __LINE__); \
54 debugBreak(); \
55 }
56#else
57 #define KR_ASSERT(expr, ...)
58 #define KR_CORE_ASSERT(expr, ...)
59#endif
60
61#define KR_BIND_EVENT_FN(fn) std::bind(&fn, this, std::placeholders::_1)
62
63// Need to write Platform.h and WindowsPlatform.h specialization for these Unreal type of defines
64// only for MSW
65#define FUNCTION_NON_NULL_RETURN_START //_Ret_notnull_ /* Indicate that the function never returns nullptr. */
66
67/* Wrap a function signature in these to indicate that the function never returns nullptr */
68#ifndef FUNCTION_NON_NULL_RETURN_START
69#define FUNCTION_NON_NULL_RETURN_START
70#endif
71#ifndef FUNCTION_NON_NULL_RETURN_END
72#define FUNCTION_NON_NULL_RETURN_END
73#endif
74
75/*
76 * For mac or appleclang inline
77 * for MSW __forceinline
78 */
79
80#ifndef FORCEINLINE
81#define FORCEINLINE inline
82#endif
83
96#define KR_NONCOPYABLE(TypeName) \
97 TypeName(TypeName&&) = delete; \
98 TypeName(const TypeName&) = delete; \
99 TypeName& operator=(const TypeName&) = delete; \
100 TypeName& operator=(TypeName&&) = delete;