Updated locale gen

This commit is contained in:
2023-02-07 21:22:57 -08:00
parent 12dd50ef77
commit c3dbacde76
13 changed files with 343 additions and 60 deletions

View File

@ -8,6 +8,15 @@ set(
DAWN_SHARED_INCLUDES
${CMAKE_CURRENT_LIST_DIR}
CACHE INTERNAL
${DAWN_CACHE_TARGET}
)
set(D ${CMAKE_CURRENT_LIST_DIR})
set(
DAWN_SHARED_SOURCES
${D}/assert/assert.cpp
CACHE INTERNAL
${DAWN_CACHE_TARGET}
)

View File

@ -0,0 +1,9 @@
# Copyright (c) 2022 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
target_sources(${DAWN_TARGET_NAME}
PRIVATE
assert.cpp
)

View File

@ -0,0 +1,40 @@
/**
* Copyright (c) 2022 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "assert.hpp"
#if ASSERTS_ENABLED == 0
#elif ASSERTS_ENABLED == 1
void assertTrue(bool_t x) {
if(x != true) {
throw "Assertion Failed";
free(0);
}
assert(x == true);
}
void assertFalse(bool_t x) {
assertTrue(!x);
}
void assertUnreachable() {
assertTrue(false);
}
void assertNotNull(void *pointer) {
assertTrue(pointer != nullptr && pointer != NULL);
}
void assertNull(void *pointer) {
assertTrue(pointer == NULL || pointer == nullptr);
}
void assertDeprecated() {
assertUnreachable();
}
#endif

View File

@ -0,0 +1,68 @@
/**
* Copyright (c) 2022 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dawnsharedlibs.hpp"
#define ASSERTS_ENABLED 1
#if ASSERTS_ENABLED == 0
static inline void assertTrue(bool_t x) {}
#elif ASSERTS_ENABLED == 1
/**
* Assert a given value to be true.
* @param x Value to assert as true.
*/
void assertTrue(bool_t x);
/**
* Asserts a given statement to be false.
* @param x Value to assert as false.
*/
void assertFalse(bool_t x);
/**
* Asserts that a given line of code is unreachable. Essentially a forced
* assertion failure, good for "edge cases"
*/
void assertUnreachable();
/**
* Assert a given pointer to not point to a null pointer.
* @param pointer Pointer to assert is not a null pointer.
*/
void assertNotNull(void *pointer);
/**
* Asserts a given pointer to be a nullptr.
* @param pointer Pointer to assert is nullptr.
*/
void assertNull(void *pointer);
/**
* Asserts a function as being deprecated.
*/
void assertDeprecated();
/**
* Asserts that a given map has a key.
*
* @param map Map to check.
* @param key Key to try and assert exists.
*/
template<typename K, typename V>
void assertMapHasKey(std::map<K,V> map, K key) {
assertTrue(map.find(key) != map.end());
}
#else
#define assertTrue assert
#endif

View File

@ -19,6 +19,7 @@ extern "C" {
#include <float.h>
typedef bool bool_t;
typedef char char_t;
}
#include <vector>
@ -28,4 +29,5 @@ extern "C" {
#include <array>
#include <memory>
#include <algorithm>
#include <sstream>
#include <sstream>
#include <string>

View File

@ -4,7 +4,7 @@
// https://opensource.org/licenses/MIT
#pragma once
#include "dawnlibs.hpp"
#include "dawnsharedlibs.hpp"
#include "assert/assert.hpp"
namespace Dawn {