Forward declare stuff for linux

This commit is contained in:
Doyle 2019-09-24 14:13:29 +10:00
parent 9dd058a5f0
commit 4a57ec6b1e
3 changed files with 41 additions and 44 deletions

View File

@ -1,6 +0,0 @@
if [ ! -d "../Bin/" ]; then
mkdir ../Bin/
fi
pushd ../Bin/
g++ ../Code/Dqn_UnitTests.cpp -std=c++17 -o Dqn_UnitTests

View File

@ -654,6 +654,40 @@ struct Dqn_MemArenaScopedRegion
#define DQN_MEM_ARENA_FREE(arena) Dqn_MemArena_Free(arena) #define DQN_MEM_ARENA_FREE(arena) Dqn_MemArena_Free(arena)
DQN_HEADER_COPY_END DQN_HEADER_COPY_END
// @ -------------------------------------------------------------------------------------------------
// @
// @ NOTE: Dqn_Allocator
// @
// @ -------------------------------------------------------------------------------------------------
DQN_HEADER_COPY_PROTOTYPE(Dqn_Allocator, inline Dqn_Allocator_NullAllocator())
{
Dqn_Allocator result = {};
result.type = Dqn_Allocator_Type::NullAllocator;
return result;
}
DQN_HEADER_COPY_PROTOTYPE(Dqn_Allocator, inline Dqn_Allocator_HeapAllocator())
{
Dqn_Allocator result = {};
result.type = Dqn_Allocator_Type::Heap;
return result;
}
DQN_HEADER_COPY_PROTOTYPE(Dqn_Allocator, inline Dqn_Allocator_XHeapAllocator())
{
Dqn_Allocator result = {};
result.type = Dqn_Allocator_Type::XHeap;
return result;
}
DQN_HEADER_COPY_PROTOTYPE(Dqn_Allocator, inline Dqn_Allocator_ArenaAllocator(Dqn_MemArena *arena))
{
Dqn_Allocator result = {};
result.type = Dqn_Allocator_Type::Arena;
result.data = arena;
return result;
}
// @ ------------------------------------------------------------------------------------------------- // @ -------------------------------------------------------------------------------------------------
// @ // @
// @ NOTE: String Builder // @ NOTE: String Builder
@ -786,6 +820,7 @@ DQN_HEADER_COPY_PROTOTYPE(template <Dqn_usize N> char *, Dqn_StringBuilder_Build
return result; return result;
} }
void *Dqn_MemArena_Alloc(Dqn_MemArena *arena, Dqn_usize size DQN_DEBUG_ARGS);
DQN_HEADER_COPY_PROTOTYPE(template <Dqn_usize N> char *, Dqn_StringBuilder_BuildFromArena(Dqn_StringBuilder<N> *builder, Dqn_MemArena *arena, Dqn_isize *len = nullptr)) DQN_HEADER_COPY_PROTOTYPE(template <Dqn_usize N> char *, Dqn_StringBuilder_BuildFromArena(Dqn_StringBuilder<N> *builder, Dqn_MemArena *arena, Dqn_isize *len = nullptr))
{ {
Dqn_isize len_w_null_terminator = Dqn_StringBuilder_BuildLen(builder); Dqn_isize len_w_null_terminator = Dqn_StringBuilder_BuildLen(builder);
@ -917,6 +952,7 @@ DQN_HEADER_COPY_PROTOTYPE(template <typename T> inline bool, Dqn_Slice_Equals(Dq
// @ NOTE: Dqn_Asprintf (Allocate Sprintf) // @ NOTE: Dqn_Asprintf (Allocate Sprintf)
// @ // @
// @ ------------------------------------------------------------------------------------------------- // @ -------------------------------------------------------------------------------------------------
int Dqn_Safe_TruncateISizeToInt(Dqn_isize val);
DQN_HEADER_COPY_PROTOTYPE(template <typename T> Dqn_Slice<char>, Dqn_AsprintfSlice(T *arena, char const *fmt, va_list va)) DQN_HEADER_COPY_PROTOTYPE(template <typename T> Dqn_Slice<char>, Dqn_AsprintfSlice(T *arena, char const *fmt, va_list va))
{ {
Dqn_Slice<char> result = {}; Dqn_Slice<char> result = {};
@ -1160,7 +1196,6 @@ DQN_HEADER_COPY_PROTOTYPE(template <typename T> void, Dqn_Array_Free(Dqn_Array<T
Dqn_Allocator_Free(&a->allocator, a->data); Dqn_Allocator_Free(&a->allocator, a->data);
} }
template <typename T> bool Dqn_Array__GrowIfNeeded(Dqn_Array<T> *a, Dqn_isize num_to_add) template <typename T> bool Dqn_Array__GrowIfNeeded(Dqn_Array<T> *a, Dqn_isize num_to_add)
{ {
Dqn_isize new_len = a->len + num_to_add; Dqn_isize new_len = a->len + num_to_add;
@ -1382,42 +1417,6 @@ DQN_HEADER_COPY_PROTOTYPE(Dqn_b32, Dqn_Log(Dqn_LogType type, char const *file, D
return true; return true;
} }
void *Dqn_MemArena_Alloc(Dqn_MemArena *arena, Dqn_usize size DQN_DEBUG_ARGS);
Dqn_b32 Dqn_MemArena_Reserve(Dqn_MemArena *arena, Dqn_usize size DQN_DEBUG_ARGS);
// @ -------------------------------------------------------------------------------------------------
// @
// @ NOTE: Dqn_Allocator
// @
// @ -------------------------------------------------------------------------------------------------
DQN_HEADER_COPY_PROTOTYPE(Dqn_Allocator, Dqn_Allocator_NullAllocator())
{
Dqn_Allocator result = {};
result.type = Dqn_Allocator_Type::NullAllocator;
return result;
}
DQN_HEADER_COPY_PROTOTYPE(Dqn_Allocator, Dqn_Allocator_HeapAllocator())
{
Dqn_Allocator result = {};
result.type = Dqn_Allocator_Type::Heap;
return result;
}
DQN_HEADER_COPY_PROTOTYPE(Dqn_Allocator, Dqn_Allocator_XHeapAllocator())
{
Dqn_Allocator result = {};
result.type = Dqn_Allocator_Type::XHeap;
return result;
}
DQN_HEADER_COPY_PROTOTYPE(Dqn_Allocator, Dqn_Allocator_ArenaAllocator(Dqn_MemArena *arena))
{
Dqn_Allocator result = {};
result.type = Dqn_Allocator_Type::Arena;
result.data = arena;
return result;
}
DQN_HEADER_COPY_PROTOTYPE(void *, Dqn_Allocator_Allocate(Dqn_Allocator *allocator, Dqn_usize size)) DQN_HEADER_COPY_PROTOTYPE(void *, Dqn_Allocator_Allocate(Dqn_Allocator *allocator, Dqn_usize size))
{ {
void *result = nullptr; void *result = nullptr;
@ -1446,6 +1445,7 @@ DQN_HEADER_COPY_PROTOTYPE(void *, Dqn_Allocator_Allocate(Dqn_Allocator *allocato
return result; return result;
} }
Dqn_b32 Dqn_MemArena_Reserve(Dqn_MemArena *arena, Dqn_usize size DQN_DEBUG_ARGS);
DQN_HEADER_COPY_PROTOTYPE(void *, Dqn_Allocator_Realloc(Dqn_Allocator *allocator, void *old_ptr, Dqn_isize old_size, Dqn_isize new_size)) DQN_HEADER_COPY_PROTOTYPE(void *, Dqn_Allocator_Realloc(Dqn_Allocator *allocator, void *old_ptr, Dqn_isize old_size, Dqn_isize new_size))
{ {
void *result = nullptr; void *result = nullptr;
@ -1922,7 +1922,6 @@ DQN_HEADER_COPY_PROTOTYPE(Dqn_b32, Dqn_Bit_IsNotSet(Dqn_u32 flags, Dqn_u32 bitfi
return result; return result;
} }
// @ ------------------------------------------------------------------------------------------------- // @ -------------------------------------------------------------------------------------------------
// @ // @
// @ NOTE: Safe Arithmetic // @ NOTE: Safe Arithmetic

4
Code/build.sh Executable file
View File

@ -0,0 +1,4 @@
mkdir -p ../Bin/
pushd ../Bin/
g++ ../Code/Dqn_UnitTests.cpp -std=c++17 -o Dqn_UnitTests
g++ ../Code/DqnHeader.h -D DQN_HEADER_IMPLEMENTATION -std=c++17 -o DqnHeader