mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 07:44:45 -08:00
Parsing constructors passed the sanity test!
This commit is contained in:
parent
ed6a1d0f95
commit
14568d512e
29
.vscode/gencpp.natvis
vendored
29
.vscode/gencpp.natvis
vendored
@ -1,6 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
|
||||
|
||||
<Type Name="StrC">
|
||||
<DisplayString>Len:{Len} Ptr:{Ptr, [Len]s}</DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name="String">
|
||||
<DisplayString Condition="Data == nullptr">null</DisplayString>
|
||||
<DisplayString>{Data,na}</DisplayString>
|
||||
@ -30,7 +34,30 @@
|
||||
<Expand>
|
||||
<Item Name="Type">Type</Item>
|
||||
<Item Name="Name">Name</Item>
|
||||
<Item Name="Parent">Parent</Item>
|
||||
<Item Name="Op" Condition="Op != 43">Op</Item>
|
||||
<Item Name="ModuleFlags">ModuleFlags</Item>
|
||||
<Item Name="ParentAcess" Condition="ParentAccess != gen::AccessSpec::Invalid">ParentAccess</Item>
|
||||
<Item Name="ArrStatic" Condition="DynamicEntries == false">ArrStatic</Item>
|
||||
<Item Name="Index" Condition="DynamicEntries == false">StaticIndex</Item>
|
||||
<Item Name="ArrDyn" Condition="DynamicEntries == true">ArrDyn</Item>
|
||||
<Item Name="Index" Condition="DynamicEntries == true">((ArrayHeader*)((char*)ArrDyn - sizeof(ArrayHeader)))->count</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="gen::Code">
|
||||
<DisplayString Condition="ast != nullptr">{ast->Name} {ast->Type}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="Type">ast->Type</Item>
|
||||
<Item Name="Name">ast->Name</Item>
|
||||
<Item Name="Parent">ast->Parent</Item>
|
||||
<Item Name="Op" Condition="ast->Op != 43">ast->Op</Item>
|
||||
<Item Name="ModuleFlags">ast->ModuleFlags</Item>
|
||||
<Item Name="ParentAcess" Condition="ast->ParentAccess != gen::AccessSpec::Invalid">ast->ParentAccess</Item>
|
||||
<Item Name="ArrStatic" Condition="ast->DynamicEntries == false">ast->ArrStatic</Item>
|
||||
<Item Name="Index" Condition="ast->DynamicEntries == false">ast->StaticIndex</Item>
|
||||
<Item Name="ArrDyn" Condition="ast->DynamicEntries == true">ast->ArrDyn</Item>
|
||||
<Item Name="Index" Condition="ast->DynamicEntries == true">((ArrayHeader*)((char*)ast->ArrDyn - sizeof(ArrayHeader)))->count</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
@ -39,7 +66,7 @@
|
||||
</Type>
|
||||
|
||||
<Type Name ="gen::Parser::Token">
|
||||
<DisplayString>Type:{Type} Text:{Text, [Length]s} Length:{Length}</DisplayString>
|
||||
<DisplayString>Length:{Length} Text:{Text, [Length]s} Type:{Type}</DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name="gen::Parser::TokArray">
|
||||
|
@ -262,7 +262,8 @@ Data Notes:
|
||||
|
||||
Two generic templated containers throughout the library:
|
||||
|
||||
`template< class Type> struct Array` and `template< class Type> struct HashTable >`
|
||||
* `template< class Type> struct Array`
|
||||
* `template< class Type> struct HashTable`
|
||||
|
||||
Otherwise the library is free of any templates.
|
||||
|
||||
|
3
gencpp.sln.DotSettings.user
Normal file
3
gencpp.sln.DotSettings.user
Normal file
@ -0,0 +1,3 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=53AF600D_002DC09C_002D4F39_002D83E0_002DE022AA9479F2_002Fd_003Athirdparty_002Ff_003Azpl_002Eh/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/SweaWarningsMode/@EntryValue">ShowAndRun</s:String></wpf:ResourceDictionary>
|
@ -103,27 +103,34 @@
|
||||
<None Include="scripts\build.ps1" />
|
||||
<None Include="scripts\clean.ps1" />
|
||||
<None Include="scripts\get_sources.ps1" />
|
||||
<None Include="scripts\meson.build" />
|
||||
<None Include="singleheader\genc.refactor" />
|
||||
<None Include="test\gen\meson.build" />
|
||||
<None Include="test\meson.build" />
|
||||
<None Include="test\Readme.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="project\Banned.define.hpp" />
|
||||
<ClInclude Include="project\Banned.undef.hpp" />
|
||||
<ClInclude Include="project\Bloat.hpp" />
|
||||
<ClInclude Include="project\Bloat.redef.hpp" />
|
||||
<ClInclude Include="project\Bloat.undef.hpp" />
|
||||
<ClInclude Include="project\gen.hpp" />
|
||||
<ClInclude Include="test\NonParsed\Sanity.hpp" />
|
||||
<ClInclude Include="test\DummyInclude.hpp" />
|
||||
<ClInclude Include="test\NonParsed\Array.NonParsed.hpp" />
|
||||
<ClInclude Include="test\NonParsed\Buffer.NonParsed.hpp" />
|
||||
<ClInclude Include="test\NonParsed\HashTable.NonParsed.hpp" />
|
||||
<ClInclude Include="test\NonParsed\Memory.NonParsed.hpp" />
|
||||
<ClInclude Include="test\NonParsed\Ring.NonParsed.hpp" />
|
||||
<ClInclude Include="test\NonParsed\Sanity.NonParsed.hpp" />
|
||||
<ClInclude Include="test\Parsed\Array.Parsed.hpp" />
|
||||
<ClInclude Include="test\Parsed\Sanity.Parsed.hpp" />
|
||||
<ClInclude Include="thirdparty\zpl.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="project\Bloat.cpp" />
|
||||
<ClCompile Include="project\gen.cpp" />
|
||||
<ClCompile Include="project\gen.singleheader.cpp" />
|
||||
<ClCompile Include="singleheader\gen\gen.singleheader.cpp" />
|
||||
<ClCompile Include="test\gen\build\meson-private\sanitycheckc.c" />
|
||||
<ClCompile Include="test\gen\build\meson-private\sanitycheckcpp.cc" />
|
||||
<ClCompile Include="test\test.cpp" />
|
||||
<ClCompile Include="test\test.NonParsed.cpp" />
|
||||
<ClCompile Include="test\test.Parsed.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Natvis Include=".vscode\gencpp.natvis" />
|
||||
|
@ -2,6 +2,165 @@
|
||||
#include "Bloat.hpp"
|
||||
|
||||
|
||||
void* gen_Arena::allocator_proc( void* allocator_data, AllocType type, sw size, sw alignment, void* old_memory, sw old_size, u64 flags )
|
||||
{
|
||||
gen_Arena* arena = rcast(gen_Arena*, allocator_data);
|
||||
void* ptr = NULL;
|
||||
|
||||
// unused( old_size );
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case EAllocation_ALLOC :
|
||||
{
|
||||
void* end = pointer_add( arena->PhysicalStart, arena->TotalUsed );
|
||||
sw total_size = align_forward_i64( size, alignment );
|
||||
|
||||
// NOTE: Out of memory
|
||||
if ( arena->TotalUsed + total_size > (sw) arena->TotalSize )
|
||||
{
|
||||
// zpl__printf_err("%s", "Arena out of memory\n");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ptr = align_forward( end, alignment );
|
||||
arena->TotalUsed += total_size;
|
||||
|
||||
if ( flags & ZPL_ALLOCATOR_FLAG_CLEAR_TO_ZERO )
|
||||
zero_size( ptr, size );
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocation_FREE :
|
||||
// NOTE: Free all at once
|
||||
// Use Temp_Arena_Memory if you want to free a block
|
||||
break;
|
||||
|
||||
case EAllocation_FREE_ALL :
|
||||
arena->TotalUsed = 0;
|
||||
break;
|
||||
|
||||
case EAllocation_RESIZE :
|
||||
{
|
||||
// TODO : Check if ptr is on top of stack and just extend
|
||||
AllocatorInfo a = arena->Backing;
|
||||
ptr = default_resize_align( a, old_memory, old_size, size, alignment );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void* gen_Pool::allocator_proc( void* allocator_data, AllocType type, sw size, sw alignment, void* old_memory, sw old_size, u64 flags )
|
||||
{
|
||||
gen_Pool* pool = zpl_cast( gen_Pool* ) allocator_data;
|
||||
void* ptr = NULL;
|
||||
|
||||
// unused( old_size );
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case EAllocation_ALLOC :
|
||||
{
|
||||
uptr next_free;
|
||||
|
||||
ZPL_ASSERT( size == pool->BlockSize );
|
||||
ZPL_ASSERT( alignment == pool->BlockAlign );
|
||||
ZPL_ASSERT( pool->FreeList != NULL );
|
||||
|
||||
next_free = *zpl_cast( uptr* ) pool->FreeList;
|
||||
ptr = pool->FreeList;
|
||||
pool->FreeList = zpl_cast( void* ) next_free;
|
||||
pool->TotalSize += pool->BlockSize;
|
||||
|
||||
if ( flags & ZPL_ALLOCATOR_FLAG_CLEAR_TO_ZERO )
|
||||
zero_size( ptr, size );
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocation_FREE :
|
||||
{
|
||||
uptr* next;
|
||||
if ( old_memory == NULL )
|
||||
return NULL;
|
||||
|
||||
next = zpl_cast( uptr* ) old_memory;
|
||||
*next = zpl_cast( uptr ) pool->FreeList;
|
||||
pool->FreeList = old_memory;
|
||||
pool->TotalSize -= pool->BlockSize;
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocation_FREE_ALL :
|
||||
{
|
||||
sw actual_block_size, block_index;
|
||||
void* curr;
|
||||
uptr* end;
|
||||
|
||||
actual_block_size = pool->BlockSize + pool->BlockAlign;
|
||||
pool->TotalSize = 0;
|
||||
|
||||
// NOTE: Init intrusive freelist
|
||||
curr = pool->PhysicalStart;
|
||||
for ( block_index = 0; block_index < pool->NumBlocks - 1; block_index++ )
|
||||
{
|
||||
uptr* next = zpl_cast( uptr* ) curr;
|
||||
*next = zpl_cast( uptr ) curr + actual_block_size;
|
||||
curr = pointer_add( curr, actual_block_size );
|
||||
}
|
||||
|
||||
end = zpl_cast( uptr* ) curr;
|
||||
*end = zpl_cast( uptr ) NULL;
|
||||
pool->FreeList = pool->PhysicalStart;
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocation_RESIZE :
|
||||
// NOTE: Cannot resize
|
||||
ZPL_PANIC( "You cannot resize something allocated by with a pool." );
|
||||
break;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
gen_Pool gen_Pool::init_align( AllocatorInfo backing, sw num_blocks, sw block_size, sw block_align )
|
||||
{
|
||||
gen_Pool pool = {};
|
||||
|
||||
sw actual_block_size, pool_size, block_index;
|
||||
void *data, *curr;
|
||||
uptr* end;
|
||||
|
||||
pool.Backing = backing;
|
||||
pool.BlockSize = block_size;
|
||||
pool.BlockAlign = block_align;
|
||||
pool.NumBlocks = num_blocks;
|
||||
|
||||
actual_block_size = block_size + block_align;
|
||||
pool_size = num_blocks * actual_block_size;
|
||||
|
||||
data = alloc_align( backing, pool_size, block_align );
|
||||
|
||||
// NOTE: Init intrusive freelist
|
||||
curr = data;
|
||||
for ( block_index = 0; block_index < num_blocks - 1; block_index++ )
|
||||
{
|
||||
uptr* next = ( uptr* ) curr;
|
||||
*next = ( uptr ) curr + actual_block_size;
|
||||
curr = pointer_add( curr, actual_block_size );
|
||||
}
|
||||
|
||||
end = ( uptr* ) curr;
|
||||
*end = ( uptr ) 0;
|
||||
|
||||
pool.PhysicalStart = data;
|
||||
pool.FreeList = data;
|
||||
|
||||
return pool;
|
||||
}
|
||||
|
||||
|
||||
namespace Memory
|
||||
{
|
||||
using namespace zpl;
|
||||
@ -16,7 +175,7 @@ namespace Memory
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case EAllocationALLOC:
|
||||
case EAllocation_ALLOC:
|
||||
{
|
||||
if ( last->total_allocated + size > last->total_size )
|
||||
{
|
||||
@ -34,15 +193,15 @@ namespace Memory
|
||||
|
||||
return alloc_align( arena_allocator( last), size, alignment );
|
||||
}
|
||||
case EAllocationFREE:
|
||||
case EAllocation_FREE:
|
||||
{
|
||||
// Doesn't recycle.
|
||||
}
|
||||
case EAllocationFREE_ALL:
|
||||
case EAllocation_FREE_ALL:
|
||||
{
|
||||
// Memory::cleanup instead.
|
||||
}
|
||||
case EAllocationRESIZE:
|
||||
case EAllocation_RESIZE:
|
||||
{
|
||||
if ( last->total_allocated + size > last->total_size )
|
||||
{
|
||||
|
@ -40,6 +40,7 @@ using zpl::sw;
|
||||
using zpl::sptr;
|
||||
using zpl::uptr;
|
||||
|
||||
using zpl::AllocType;
|
||||
using zpl::Arena;
|
||||
using zpl::AllocatorInfo;
|
||||
using zpl::ArrayHeader;
|
||||
@ -48,9 +49,17 @@ using zpl::FileError;
|
||||
using zpl::Pool;
|
||||
// using zpl::String;
|
||||
|
||||
using zpl::EAllocation_ALLOC;
|
||||
using zpl::EAllocation_FREE;
|
||||
using zpl::EAllocation_FREE_ALL;
|
||||
using zpl::EAllocation_RESIZE;
|
||||
using zpl::EFileMode_WRITE;
|
||||
using zpl::EFileError_NONE;
|
||||
|
||||
using zpl::ZPL_ALLOCATOR_FLAG_CLEAR_TO_ZERO;
|
||||
|
||||
using zpl::align_forward;
|
||||
using zpl::align_forward_i64;
|
||||
using zpl::alloc;
|
||||
using zpl::alloc_align;
|
||||
using zpl::arena_allocator;
|
||||
@ -58,7 +67,6 @@ using zpl::arena_init_from_memory;
|
||||
using zpl::arena_init_from_allocator;
|
||||
using zpl::arena_free;
|
||||
using zpl::assert_crash;
|
||||
using zpl::str_fmt_buf;
|
||||
using zpl::char_first_occurence;
|
||||
using zpl::char_is_alpha;
|
||||
using zpl::char_is_alphanumeric;
|
||||
@ -67,19 +75,23 @@ using zpl::char_is_hex_digit;
|
||||
using zpl::char_is_space;
|
||||
using zpl::crc32;
|
||||
using zpl::free_all;
|
||||
using zpl::is_power_of_two;
|
||||
using zpl::mem_copy;
|
||||
using zpl::mem_move;
|
||||
using zpl::mem_set;
|
||||
using zpl::pointer_add;
|
||||
using zpl::pool_allocator;
|
||||
using zpl::pool_init;
|
||||
using zpl::pool_free;
|
||||
using zpl::process_exit;
|
||||
using zpl::str_compare;
|
||||
using zpl::str_copy;
|
||||
using zpl::str_fmt_buf;
|
||||
using zpl::str_fmt_va;
|
||||
using zpl::str_fmt_out_va;
|
||||
using zpl::str_fmt_out_err_va;
|
||||
using zpl::str_compare;
|
||||
using zpl::str_len;
|
||||
using zpl::zero_size;
|
||||
|
||||
#if __clang__
|
||||
# pragma clang diagnostic pop
|
||||
@ -141,14 +153,13 @@ using zpl::str_len;
|
||||
#define bit( Value_ ) ( 1 << Value_ )
|
||||
#define bitfield_is_equal( Type_, Field_, Mask_ ) ( (Type_(Mask_) & Type_(Field_)) == Type_(Mask_) )
|
||||
#define forceinline ZPL_ALWAYS_INLINE
|
||||
#define print_nl( _) zpl_printf("\n")
|
||||
#define ccast( Type_, Value_ ) * const_cast< Type_* >( & (Value_) )
|
||||
#define scast( Type_, Value_ ) static_cast< Type_ >( Value_ )
|
||||
#define rcast( Type_, Value_ ) reinterpret_cast< Type_ >( Value_ )
|
||||
#define pcast( Type_, Value_ ) ( * (Type_*)( & (Value_) ) )
|
||||
#define txt_impl( ... ) #__VA_ARGS__
|
||||
#define txt( ... ) txt_impl( __VA_ARGS__ )
|
||||
#define txt_n_len( ... ) sizeof( txt_impl( __VA_ARGS__ ) ), txt_impl( __VA_ARGS__ )
|
||||
#define GEN_STRINGIZE_VA( ... ) #__VA_ARGS__
|
||||
#define txt( ... ) GEN_STRINGIZE_VA( __VA_ARGS__ )
|
||||
#define txt_to_StrC( ... ) sizeof( GEN_STRINGIZE_VA( __VA_ARGS__ ) ), GEN_STRINGIZE_VA( __VA_ARGS__ )
|
||||
#define do_once() \
|
||||
do \
|
||||
{ \
|
||||
@ -176,10 +187,127 @@ while(0);
|
||||
constexpr
|
||||
char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";
|
||||
|
||||
#pragma region Memory
|
||||
|
||||
// TODO : Use it.
|
||||
struct gen_Arena
|
||||
{
|
||||
static
|
||||
void* allocator_proc( void* allocator_data, AllocType type, sw size, sw alignment, void* old_memory, sw old_size, u64 flags );
|
||||
|
||||
static
|
||||
gen_Arena init_from_memory( void* start, sw size )
|
||||
{
|
||||
return
|
||||
{
|
||||
{ nullptr, nullptr },
|
||||
start,
|
||||
size,
|
||||
0,
|
||||
0
|
||||
};
|
||||
}
|
||||
|
||||
static
|
||||
gen_Arena init_from_allocator( AllocatorInfo backing, sw size )
|
||||
{
|
||||
gen_Arena result =
|
||||
{
|
||||
backing,
|
||||
alloc( backing, size),
|
||||
size,
|
||||
0,
|
||||
0
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
static
|
||||
gen_Arena init_sub( gen_Arena& parent, sw size )
|
||||
{
|
||||
return init_from_allocator( parent.Backing, size );
|
||||
}
|
||||
|
||||
sw alignment_of( sw alignment )
|
||||
{
|
||||
sw alignment_offset, result_pointer, mask;
|
||||
ZPL_ASSERT( is_power_of_two( alignment ) );
|
||||
|
||||
alignment_offset = 0;
|
||||
result_pointer = (sw) PhysicalStart + TotalUsed;
|
||||
mask = alignment - 1;
|
||||
|
||||
if ( result_pointer & mask )
|
||||
alignment_offset = alignment - ( result_pointer & mask );
|
||||
|
||||
return alignment_offset;
|
||||
}
|
||||
|
||||
void check()
|
||||
{
|
||||
ZPL_ASSERT( TempCount == 0 );
|
||||
}
|
||||
|
||||
void free()
|
||||
{
|
||||
if ( Backing.proc )
|
||||
{
|
||||
zpl::free( Backing, PhysicalStart );
|
||||
PhysicalStart = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
sw size_remaining( sw alignment )
|
||||
{
|
||||
sw result = TotalSize - ( TotalUsed + alignment_of( alignment ) );
|
||||
return result;
|
||||
}
|
||||
|
||||
AllocatorInfo Backing;
|
||||
void* PhysicalStart;
|
||||
sw TotalSize;
|
||||
sw TotalUsed;
|
||||
sw TempCount;
|
||||
};
|
||||
|
||||
struct gen_Pool
|
||||
{
|
||||
static
|
||||
void* allocator_proc( void* allocator_data, AllocType type, sw size, sw alignment, void* old_memory, sw old_size, u64 flags );
|
||||
|
||||
static
|
||||
gen_Pool init( AllocatorInfo backing, sw num_blocks, sw block_size )
|
||||
{
|
||||
return init_align( backing, num_blocks, block_size, ZPL_DEFAULT_MEMORY_ALIGNMENT );
|
||||
}
|
||||
|
||||
static
|
||||
gen_Pool init_align( AllocatorInfo backing, sw num_blocks, sw block_size, sw block_align );
|
||||
|
||||
void free()
|
||||
{
|
||||
if ( Backing.proc )
|
||||
{
|
||||
zpl::free( Backing, PhysicalStart );
|
||||
}
|
||||
}
|
||||
|
||||
AllocatorInfo Backing;
|
||||
void* PhysicalStart;
|
||||
void* FreeList;
|
||||
sw BlockSize;
|
||||
sw BlockAlign;
|
||||
sw TotalSize;
|
||||
sw NumBlocks;
|
||||
};
|
||||
|
||||
#pragma endregion Memory
|
||||
|
||||
#pragma region Containers
|
||||
#pragma push_macro("template")
|
||||
#undef template
|
||||
|
||||
// TODO : Use it.
|
||||
template<class Type>
|
||||
struct TArray
|
||||
{
|
||||
@ -191,13 +319,13 @@ struct TArray
|
||||
};
|
||||
|
||||
static
|
||||
TArray<Type> init( AllocatorInfo allocator )
|
||||
TArray init( AllocatorInfo allocator )
|
||||
{
|
||||
return init_reserve( allocator, grow_formula(0) );
|
||||
}
|
||||
|
||||
static
|
||||
TArray<Type> init_reserve( AllocatorInfo allocator, sw capacity )
|
||||
TArray init_reserve( AllocatorInfo allocator, sw capacity )
|
||||
{
|
||||
Header* header = rcast( Header*, alloc( allocator, sizeof(Header) + sizeof(Type) ));
|
||||
|
||||
@ -369,6 +497,7 @@ struct TArray
|
||||
}
|
||||
};
|
||||
|
||||
// TODO : Use it.
|
||||
template<typename Type>
|
||||
struct THashTable
|
||||
{
|
||||
@ -387,7 +516,7 @@ struct THashTable
|
||||
};
|
||||
|
||||
static
|
||||
THashTable<Type> init( AllocatorInfo allocator )
|
||||
THashTable init( AllocatorInfo allocator )
|
||||
{
|
||||
THashTable<Type> result = {0};
|
||||
|
||||
@ -621,9 +750,6 @@ protected:
|
||||
#pragma pop_macro("template")
|
||||
#pragma endregion Containers
|
||||
|
||||
#pragma region Memory
|
||||
#pragma endregion Memory
|
||||
|
||||
#pragma region String
|
||||
// Constant string with length.
|
||||
struct StrC
|
||||
|
810
project/gen.cpp
810
project/gen.cpp
File diff suppressed because it is too large
Load Diff
129
project/gen.hpp
129
project/gen.hpp
@ -65,6 +65,8 @@ namespace gen
|
||||
Entry( Operator_Fwd ) \
|
||||
Entry( Operator_Member ) \
|
||||
Entry( Operator_Member_Fwd ) \
|
||||
Entry( Operator_Cast ) \
|
||||
Entry( Operator_Cast_Fwd ) \
|
||||
Entry( Parameters ) \
|
||||
Entry( Preprocessor_Include ) \
|
||||
Entry( Specifiers ) \
|
||||
@ -95,7 +97,7 @@ namespace gen
|
||||
{
|
||||
static
|
||||
StrC lookup[Num_Types] = {
|
||||
# define Entry( Type ) { txt_n_len( Type ) },
|
||||
# define Entry( Type ) { txt_to_StrC( Type ) },
|
||||
Define_Types
|
||||
# undef Entry
|
||||
};
|
||||
@ -132,11 +134,11 @@ namespace gen
|
||||
Entry( Assign, = ) \
|
||||
Entry( Assign_Add, += ) \
|
||||
Entry( Assign_Subtract, -= ) \
|
||||
Entry( Assgin_Multiply, *= ) \
|
||||
Entry( Assgin_Divide, /= ) \
|
||||
Entry( Assgin_Modulo, %= ) \
|
||||
Entry( Assgin_BAnd, &= ) \
|
||||
Entry( Assgin_BOr, |= ) \
|
||||
Entry( Assign_Multiply, *= ) \
|
||||
Entry( Assign_Divide, /= ) \
|
||||
Entry( Assign_Modulo, %= ) \
|
||||
Entry( Assign_BAnd, &= ) \
|
||||
Entry( Assign_BOr, |= ) \
|
||||
Entry( Assign_BXOr, ^= ) \
|
||||
Entry( Assign_LShift, <<= ) \
|
||||
Entry( Assign_RShift, >>= ) \
|
||||
@ -144,6 +146,7 @@ namespace gen
|
||||
Entry( Decrement, -- ) \
|
||||
Entry( Unary_Plus, + ) \
|
||||
Entry( Unary_Minus, - ) \
|
||||
Entry( UnaryNot, ! ) \
|
||||
Entry( Add, + ) \
|
||||
Entry( Subtract, - ) \
|
||||
Entry( Multiply, * ) \
|
||||
@ -155,11 +158,10 @@ namespace gen
|
||||
Entry( BXOr, ^ ) \
|
||||
Entry( LShift, << ) \
|
||||
Entry( RShift, >> ) \
|
||||
Entry( LNot, ! ) \
|
||||
Entry( LAnd, && ) \
|
||||
Entry( LOr, || ) \
|
||||
Entry( Equals, == ) \
|
||||
Entry( NotEquals, != ) \
|
||||
Entry( LEqual, == ) \
|
||||
Entry( LNot, != ) \
|
||||
Entry( Lesser, < ) \
|
||||
Entry( Greater, > ) \
|
||||
Entry( LesserEqual, <= ) \
|
||||
@ -250,7 +252,7 @@ namespace gen
|
||||
# define internal internal
|
||||
# define local_persist local_persist
|
||||
|
||||
# define Entry( Spec_, Code_ ) { txt_n_len(Code_) },
|
||||
# define Entry( Spec_, Code_ ) { txt_to_StrC(Code_) },
|
||||
Define_Specifiers
|
||||
# undef Entry
|
||||
|
||||
@ -272,7 +274,9 @@ namespace gen
|
||||
{
|
||||
StrC enum_str = to_str( (Type)index );
|
||||
|
||||
keymap[index] = crc32( enum_str.Ptr, enum_str.Len);
|
||||
// We subtract 1 to remove the null terminator
|
||||
// This is because the tokens lexed are not null terminated.
|
||||
keymap[index] = crc32( enum_str.Ptr, enum_str.Len - 1);
|
||||
}
|
||||
do_once_end
|
||||
|
||||
@ -398,7 +402,6 @@ namespace gen
|
||||
# pragma region Member Functions
|
||||
void add_entry( AST* other );
|
||||
|
||||
inline
|
||||
AST* body()
|
||||
{
|
||||
return entry( 0 );
|
||||
@ -411,22 +414,18 @@ namespace gen
|
||||
return DynamicEntries ? ArrDyn[ idx ] : ArrStatic[ idx ];
|
||||
}
|
||||
|
||||
inline
|
||||
bool has_entries()
|
||||
{
|
||||
return num_entries();
|
||||
}
|
||||
|
||||
inline
|
||||
bool is_invalid()
|
||||
{
|
||||
return Type != ECode::Invalid;
|
||||
}
|
||||
|
||||
inline
|
||||
bool is_equal( AST* other );
|
||||
|
||||
inline
|
||||
s32 num_entries()
|
||||
{
|
||||
return DynamicEntries ? array_count( ArrDyn ) : StaticIndex;
|
||||
@ -434,7 +433,6 @@ namespace gen
|
||||
|
||||
// Parameter
|
||||
|
||||
inline
|
||||
AST* get_param( s32 index )
|
||||
{
|
||||
if ( index <= 0 )
|
||||
@ -443,14 +441,12 @@ namespace gen
|
||||
return entry( index + 1 );
|
||||
}
|
||||
|
||||
inline
|
||||
s32 param_count()
|
||||
{
|
||||
// The first entry (which holds the type) represents the first parameter.
|
||||
return num_entries();
|
||||
}
|
||||
|
||||
inline
|
||||
AST* param_type()
|
||||
{
|
||||
return entry( 0 );
|
||||
@ -458,7 +454,6 @@ namespace gen
|
||||
|
||||
// Specifiers
|
||||
|
||||
inline
|
||||
bool add_specifier( SpecifierT spec )
|
||||
{
|
||||
if ( StaticIndex == AST::ArrSpecs_Cap )
|
||||
@ -472,7 +467,6 @@ namespace gen
|
||||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
s32 has_specifier( SpecifierT spec )
|
||||
{
|
||||
for ( s32 idx = 0; idx < StaticIndex; idx++ )
|
||||
@ -486,21 +480,18 @@ namespace gen
|
||||
|
||||
// Typename
|
||||
|
||||
inline
|
||||
bool typename_is_ptr()
|
||||
{
|
||||
assert_crash("not implemented");
|
||||
return false;
|
||||
}
|
||||
|
||||
inline
|
||||
bool typename_is_ref()
|
||||
{
|
||||
assert_crash("not implemented");
|
||||
return false;
|
||||
}
|
||||
|
||||
inline
|
||||
AST* typename_specifiers()
|
||||
{
|
||||
return entry( 0 );
|
||||
@ -508,7 +499,6 @@ namespace gen
|
||||
|
||||
// Serialization
|
||||
|
||||
inline
|
||||
char const* debug_str()
|
||||
{
|
||||
char const* fmt = txt(
|
||||
@ -530,7 +520,6 @@ namespace gen
|
||||
);
|
||||
}
|
||||
|
||||
inline
|
||||
char const* type_str()
|
||||
{
|
||||
return ECode::to_str( Type );
|
||||
@ -582,9 +571,6 @@ namespace gen
|
||||
# undef Using_CodePOD
|
||||
};
|
||||
|
||||
constexpr sw size_AST = sizeof(AST);
|
||||
constexpr sw size_POD = sizeof(AST_POD);
|
||||
|
||||
// Its intended for the AST to have equivalent size to its POD.
|
||||
// All extra functionality within the AST namespace should just be syntatic sugar.
|
||||
static_assert( sizeof(AST) == sizeof(AST_POD), "ERROR: AST IS NOT POD" );
|
||||
@ -604,7 +590,6 @@ namespace gen
|
||||
# pragma endregion Statics
|
||||
|
||||
# pragma region Member Functions
|
||||
inline
|
||||
Code body()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
@ -622,13 +607,11 @@ namespace gen
|
||||
return { ast->body() };
|
||||
}
|
||||
|
||||
inline
|
||||
String to_string() const
|
||||
{
|
||||
return ast->to_string();
|
||||
}
|
||||
|
||||
inline
|
||||
void set_global()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
@ -640,45 +623,34 @@ namespace gen
|
||||
ast->Parent = Global.ast;
|
||||
}
|
||||
|
||||
inline
|
||||
operator bool() const
|
||||
bool is_valid()
|
||||
{
|
||||
return ast;
|
||||
// Originally intended to use operator bool(), however for some reason
|
||||
// The C++ standard has operator Type*() with higher precedence than operator bool().
|
||||
// Even when directly casting to bool. Amazing.
|
||||
return ast != nullptr && ast->Type != ECode::Invalid;
|
||||
}
|
||||
|
||||
operator bool() const
|
||||
{
|
||||
return ast != nullptr && ast->Type != ECode::Invalid;
|
||||
}
|
||||
|
||||
inline
|
||||
bool operator ==( Code other )
|
||||
{
|
||||
return ast == other.ast;
|
||||
}
|
||||
|
||||
inline
|
||||
bool operator !=( Code other )
|
||||
{
|
||||
return ast != other.ast;
|
||||
}
|
||||
|
||||
inline
|
||||
operator AST*()
|
||||
{
|
||||
return ast;
|
||||
}
|
||||
|
||||
inline
|
||||
Code& operator=( Code other )
|
||||
{
|
||||
if ( other.ast == nullptr )
|
||||
{
|
||||
log_failure("Attempted to assign a nullptr!");
|
||||
return *this;
|
||||
}
|
||||
|
||||
ast = other.ast;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
AST* operator->()
|
||||
{
|
||||
if ( ast == nullptr )
|
||||
@ -732,12 +704,12 @@ namespace gen
|
||||
// Set these before calling gen's init() procedure.
|
||||
// Data
|
||||
|
||||
void set_allocator_data_arrays ( AllocatorInfo data_array_allocator );
|
||||
void set_allocator_code_pool ( AllocatorInfo pool_allocator );
|
||||
void set_allocator_code_enries_arena( AllocatorInfo pool_allocator );
|
||||
void set_allocator_string_arena ( AllocatorInfo string_allocator );
|
||||
void set_allocator_string_table ( AllocatorInfo string_allocator );
|
||||
void set_allocator_type_table ( AllocatorInfo type_reg_allocator );
|
||||
void set_allocator_data_arrays ( AllocatorInfo data_array_allocator );
|
||||
void set_allocator_code_pool ( AllocatorInfo pool_allocator );
|
||||
void set_allocator_code_enrties_arena( AllocatorInfo pool_allocator );
|
||||
void set_allocator_string_arena ( AllocatorInfo string_allocator );
|
||||
void set_allocator_string_table ( AllocatorInfo string_allocator );
|
||||
void set_allocator_type_table ( AllocatorInfo type_reg_allocator );
|
||||
|
||||
# pragma region Upfront
|
||||
Code def_attributes( StrC content );
|
||||
@ -772,6 +744,8 @@ namespace gen
|
||||
, Code specifiers = NoCode, Code attributes = NoCode
|
||||
, ModuleFlag mflags = ModuleFlag::None );
|
||||
|
||||
Code def_operator_cast( Code type, Code body = NoCode );
|
||||
|
||||
Code def_param ( Code type, StrC name, Code value = NoCode );
|
||||
Code def_specifier( SpecifierT specifier );
|
||||
|
||||
@ -824,22 +798,23 @@ namespace gen
|
||||
|
||||
# pragma region Parsing
|
||||
# ifdef GEN_FEATURE_PARSING
|
||||
Code parse_class ( StrC class_def );
|
||||
Code parse_enum ( StrC enum_def );
|
||||
Code parse_export_body ( StrC export_def );
|
||||
Code parse_extern_link ( StrC exten_link_def);
|
||||
Code parse_friend ( StrC friend_def );
|
||||
Code parse_function ( StrC fn_def );
|
||||
Code parse_global_body ( StrC body_def );
|
||||
Code parse_namespace ( StrC namespace_def );
|
||||
Code parse_operator ( StrC operator_def );
|
||||
Code parse_struct ( StrC struct_def );
|
||||
Code parse_template ( StrC template_def );
|
||||
Code parse_type ( StrC type_def );
|
||||
Code parse_typedef ( StrC typedef_def );
|
||||
Code parse_union ( StrC union_def );
|
||||
Code parse_using ( StrC using_def );
|
||||
Code parse_variable ( StrC var_def );
|
||||
Code parse_class ( StrC class_def );
|
||||
Code parse_enum ( StrC enum_def );
|
||||
Code parse_export_body ( StrC export_def );
|
||||
Code parse_extern_link ( StrC exten_link_def);
|
||||
Code parse_friend ( StrC friend_def );
|
||||
Code parse_function ( StrC fn_def );
|
||||
Code parse_global_body ( StrC body_def );
|
||||
Code parse_namespace ( StrC namespace_def );
|
||||
Code parse_operator ( StrC operator_def );
|
||||
Code parse_operator_cast( StrC operator_def );
|
||||
Code parse_struct ( StrC struct_def );
|
||||
Code parse_template ( StrC template_def );
|
||||
Code parse_type ( StrC type_def );
|
||||
Code parse_typedef ( StrC typedef_def );
|
||||
Code parse_union ( StrC union_def );
|
||||
Code parse_using ( StrC using_def );
|
||||
Code parse_variable ( StrC var_def );
|
||||
# endif
|
||||
# pragma endregion Parsing
|
||||
|
||||
@ -994,10 +969,10 @@ namespace gen
|
||||
|
||||
// Convienence for defining any name used with the gen api.
|
||||
// Lets you provide the length and string literal to the functions without the need for the DSL.
|
||||
# define name( Id_ ) { txt_n_len( Id_ ) }
|
||||
# define name( Id_ ) { txt_to_StrC( Id_ ) }
|
||||
|
||||
// Same as name just used to indicate intention of literal for code instead of names.
|
||||
# define code( ... ) { txt_n_len( __VA_ARGS__ ) }
|
||||
# define code( ... ) { txt_to_StrC( __VA_ARGS__ ) }
|
||||
#pragma endregion Macros
|
||||
|
||||
#pragma region Constants
|
||||
|
28
project/gen.undef.macros.hpp
Normal file
28
project/gen.undef.macros.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
#if gen_time
|
||||
// This undefines the macros used by the gen library but are not necessary for the user.
|
||||
// TODO : This is incomplete until all dependencies are brough in from ZPL into bloat.
|
||||
|
||||
#undef bit
|
||||
#undef bitfield_is_equal
|
||||
#undef ccast
|
||||
#undef scast
|
||||
#undef rcast
|
||||
#undef pcast
|
||||
#undef do_once
|
||||
#undef do_once_start
|
||||
#undef do_once_end
|
||||
|
||||
#undef kilobytes
|
||||
#undef megabytes
|
||||
#undef gigabytes
|
||||
#undef terabytes
|
||||
|
||||
#undef global
|
||||
#undef internal
|
||||
#undef local_persist
|
||||
#undef forceinline
|
||||
|
||||
#undef txt
|
||||
|
||||
// gen_time
|
||||
#endif
|
230
scripts/gencpp.refactor
Normal file
230
scripts/gencpp.refactor
Normal file
@ -0,0 +1,230 @@
|
||||
__VERSION 1
|
||||
|
||||
// This is a example template to be used with the refactor program
|
||||
// Use it to refactor the naming convention of this library to your own.
|
||||
// Can be used as an aid to help use use your project's implementation if it fullfills the dependencies of this project.
|
||||
// Example: Most likely have a memory and string library already, just rename the functions and make sure the args are the same.
|
||||
// Program: https://github.com/Ed94/refactor
|
||||
|
||||
// NOTE: Due to the current limitations of the program, not every symbol in the library can be renamed.
|
||||
// This is due to the program not actually parsing C/C++.
|
||||
|
||||
// not : Ignore
|
||||
// include : #includes
|
||||
// word : Alphanumeric or underscore
|
||||
// namespace : Prefix search and replace (c-namspaces).
|
||||
// regex : Unavailable in __VERSION 1.
|
||||
|
||||
// Precedence (highest to lowest):
|
||||
// word, namespace, regex
|
||||
|
||||
// Basic Types
|
||||
|
||||
// word b32 new_name
|
||||
// word s8 new_name
|
||||
// word s64 new_name
|
||||
// word u8 new_name
|
||||
// word u32 new_name
|
||||
// word u64 new_name
|
||||
// word uw new_name
|
||||
// word sw new_name
|
||||
// word sptr new_name
|
||||
// word uptr new_name
|
||||
|
||||
// ZPL Derived
|
||||
|
||||
// namespace EAllocator_ new_namespace_
|
||||
// namespace EFileMode_ new_namespace_
|
||||
// namespace EFileError_ new_namespace_
|
||||
|
||||
// word Arena new_name
|
||||
// word AllocatorInfo new_name
|
||||
// word ArrayHeader new_name
|
||||
// word FileInfo new_name
|
||||
// word FileError new_name
|
||||
// word Pool new_name
|
||||
|
||||
// word Array new_name
|
||||
// word HashTable new_name
|
||||
|
||||
// word alloc new_name
|
||||
// word alloc_align new_name
|
||||
// word assert_crash new_name
|
||||
// word char_first_occurence new_name
|
||||
// word char_is_alpha new_name
|
||||
// word char_is_alphanumeric new_name
|
||||
// word char_is_digit new_name
|
||||
// word char_is_hex_digit new_name
|
||||
// word char_is_space new_name
|
||||
// word crc32 new_name
|
||||
// word free_all new_name
|
||||
// word mem_copy new_name
|
||||
// word mem_move new_name
|
||||
// word mem_set new_name
|
||||
// word process_exit new_name
|
||||
// word str_compare new_name
|
||||
// word str_copy new_name
|
||||
// word str_fmt_buf new_name
|
||||
// word str_fmt_va new_name
|
||||
// word str_fmt_out_va new_name
|
||||
// word str_fmt_out_err_va new_name
|
||||
// word str_len new_name
|
||||
|
||||
// generic API
|
||||
|
||||
// word to_str new_name
|
||||
// word to_type new_name
|
||||
|
||||
// gencpp Types & Constants
|
||||
|
||||
// word LogFailType new_name
|
||||
// word log_failure new_name
|
||||
|
||||
// word ECode new_name
|
||||
// word EnumT new_name
|
||||
// word EnumClass new_name
|
||||
// word EnumRegular new_name
|
||||
// word UsingT new_name
|
||||
// word UsingRegular new_name
|
||||
// word UsingNamespace new_name
|
||||
// word EOperator new_name
|
||||
// word OperatorT new_name
|
||||
// word ESpecifier new_name
|
||||
// word SpecifierT new_name
|
||||
// word AccessSpec new_name
|
||||
// word ModuleFlag new_name
|
||||
|
||||
// word API_Export new_name
|
||||
// word API_Import new_name
|
||||
// word Keyword new_name
|
||||
|
||||
// gencpp Data
|
||||
|
||||
// word StringTable new_name
|
||||
// word StringCached new_name
|
||||
// word AST_POD_Size new_name
|
||||
// word AST new_name
|
||||
// word AST_POD new_name
|
||||
// word Code new_name
|
||||
// word Code_POD new_name
|
||||
// word NoCode new_name
|
||||
|
||||
// gencpp API
|
||||
|
||||
// word init new_name
|
||||
// word deinit new_name
|
||||
|
||||
// word get_cached_string new_name
|
||||
// word make_code new_name
|
||||
// word make_code_entries new_name
|
||||
|
||||
// word set_allocator_data_arrays new_name
|
||||
// word set_allocator_code_pool new_name
|
||||
// word set_allocator_code_entries_arena new_name
|
||||
// word set_allocator_string_arena new_name
|
||||
// word set_allocator_string_table new_name
|
||||
// word set_allocator_type_table new_name
|
||||
|
||||
// upfront constructor namespace
|
||||
// namespace def_ new_namespace_
|
||||
|
||||
// upfront constructor individual
|
||||
|
||||
// word def_attributes new_name
|
||||
// word def_comment new_name
|
||||
// word def_class new_name
|
||||
// word def_enum new_name
|
||||
// word def_execution new_name
|
||||
// word def_extern_link new_name
|
||||
// word def_friend new_name
|
||||
// word def_function new_name
|
||||
// word def_include new_name
|
||||
// word def_module new_name
|
||||
// word def_namespace new_name
|
||||
// word def_operator new_name
|
||||
// word def_param new_name
|
||||
// word def_specifier new_name
|
||||
// word def_struct new_name
|
||||
// word def_template new_name
|
||||
// word def_type new_name
|
||||
// word def_typedef new_name
|
||||
// word def_union new_name
|
||||
// word def_using new_name
|
||||
// word def_using_namespace new_name
|
||||
// word def_variable new_name
|
||||
|
||||
// word def_class_body new_name
|
||||
// word def_class_body new_name
|
||||
// word def_enum_body new_name
|
||||
// word def_enum_body new_name
|
||||
// word def_export_body new_name
|
||||
// word def_export_body new_name
|
||||
// word def_extern_link_body new_name
|
||||
// word def_extern_link_body new_name
|
||||
// word def_function_body new_name
|
||||
// word def_function_body new_name
|
||||
// word def_global_body new_name
|
||||
// word def_global_body new_name
|
||||
// word def_namespace_body new_name
|
||||
// word def_namespace_body new_name
|
||||
// word def_params new_name
|
||||
// word def_params new_name
|
||||
// word def_specifiers new_name
|
||||
// word def_specifiers new_name
|
||||
// word def_struct_body new_name
|
||||
// word def_struct_body new_name
|
||||
// word def_union_body new_name
|
||||
// word def_union_body new_name
|
||||
|
||||
// parse constructor namespace
|
||||
// namespace parse_ new_namespace_
|
||||
|
||||
// parse constructor individual
|
||||
|
||||
// word parse_class new_name
|
||||
// word parse_enum new_name
|
||||
// word parse_export_body new_name
|
||||
// word parse_extern_link new_name
|
||||
// word parse_friend new_name
|
||||
// word parse_function new_name
|
||||
// word parse_global_body new_name
|
||||
// word parse_namespace new_name
|
||||
// word parse_operator new_name
|
||||
// word parse_struct new_name
|
||||
// word parse_template new_name
|
||||
// word parse_type new_name
|
||||
// word parse_typedef new_name
|
||||
// word parse_union new_name
|
||||
// word parse_using new_name
|
||||
// word parse_variable new_name
|
||||
|
||||
// untyped constructor namespace
|
||||
// namespace untyped_ new_namespace_
|
||||
|
||||
// untyped constructor individual
|
||||
|
||||
// word token_fmt_va new_name
|
||||
// word token_fmt new_name
|
||||
// word untyped_str new_name
|
||||
// word untyped_fmt new_name
|
||||
// word untyped_token_fmt new_name
|
||||
|
||||
// File Handling
|
||||
|
||||
// word Builder new_name
|
||||
// word Editor new_name
|
||||
// word Scanner new_name
|
||||
|
||||
// gencpp macros
|
||||
|
||||
// word __ new_name
|
||||
// word code new_name
|
||||
// word name new_name
|
||||
// word txt new_name
|
||||
// word txt_to_StrC new_name
|
||||
|
||||
// Type AST namespace
|
||||
// namespace t_ new_namespace_
|
||||
|
||||
// Specifier AST namespace
|
||||
// namespace spec_ new_namespace_
|
@ -258,12 +258,9 @@ Code gen__array( StrC type, sw type_size )
|
||||
set_capacity = def_function( name(set_capacity), def_param( t_uw, name(new_capacity)), t_bool, body );
|
||||
}
|
||||
|
||||
Code op_ptr = untyped_str( code(
|
||||
operator Type*()
|
||||
{
|
||||
return Data;
|
||||
}
|
||||
));
|
||||
Code op_ptr = def_operator_cast( t_type_ptr, def_execution( code(
|
||||
return Data;
|
||||
)));
|
||||
|
||||
Code body = def_struct_body( 20
|
||||
, using_header
|
||||
@ -327,7 +324,7 @@ void gen__array_request( StrC type, sw size, StrC dep = {} )
|
||||
GenArrayRequest request = { dep, type, size };
|
||||
array_append( GenArrayRequests, request );
|
||||
}
|
||||
#define gen_array( type ) gen__array_request( { txt_n_len(type) }, sizeof(type) )
|
||||
#define gen_array( type ) gen__array_request( { txt_to_StrC(type) }, sizeof(type) )
|
||||
|
||||
u32 gen_array_file()
|
||||
{
|
||||
|
@ -172,12 +172,9 @@ Code gen__buffer( StrC type, sw type_size )
|
||||
))
|
||||
);
|
||||
|
||||
Code op_type_ptr = untyped_str( code(
|
||||
operator Type*()
|
||||
{
|
||||
return Data;
|
||||
}
|
||||
));
|
||||
Code op_type_ptr = def_operator_cast( t_type_ptr, def_execution( code(
|
||||
return Data;
|
||||
)));
|
||||
|
||||
buffer = def_struct( name, def_struct_body( 14
|
||||
, using_header
|
||||
@ -232,7 +229,7 @@ void gen__buffer_request( StrC type, sw size, StrC dep = {} )
|
||||
GenBufferRequest request = { dep, type, size};
|
||||
array_append( GenBufferRequests, request );
|
||||
}
|
||||
#define gen_buffer( type ) gen__buffer_request( { txt_n_len(type) }, sizeof( type ))
|
||||
#define gen_buffer( type ) gen__buffer_request( { txt_to_StrC(type) }, sizeof( type ))
|
||||
|
||||
u32 gen_buffer_file()
|
||||
{
|
||||
|
@ -425,7 +425,7 @@ void gen__hashtable_request( StrC type, sw size, StrC dep = {} )
|
||||
GenHashTableRequest request = { dep, type, size};
|
||||
array_append( GenHashTableRequests, request );
|
||||
}
|
||||
#define gen_hashtable( type ) gen__hashtable_request( { txt_n_len(type) }, sizeof( type ))
|
||||
#define gen_hashtable( type ) gen__hashtable_request( { txt_to_StrC(type) }, sizeof( type ))
|
||||
|
||||
u32 gen_hashtable_file()
|
||||
{
|
||||
|
@ -188,7 +188,7 @@ void gen__ring_request( StrC type, sw size, StrC dep = {} )
|
||||
GenRingRequest request = { dep, type, size};
|
||||
array_append( GenRingRequests, request );
|
||||
}
|
||||
#define gen_ring( type ) gen__ring_request( { txt_n_len(type) }, sizeof( type ))
|
||||
#define gen_ring( type ) gen__ring_request( { txt_to_StrC(type) }, sizeof( type ))
|
||||
|
||||
u32 gen_ring_file()
|
||||
{
|
||||
|
@ -190,6 +190,19 @@ u32 gen_sanity()
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Operator cast
|
||||
{
|
||||
Code t_u8_ptr = def_type( name(u8), __, spec_ptr );
|
||||
|
||||
Code op_ptr = def_operator_cast( t_u8_ptr, __ );
|
||||
|
||||
Code op_class = def_class( name(TestOperatorCast), def_class_body( 1, op_ptr ) );
|
||||
|
||||
gen_sanity_file.print(op_class);
|
||||
}
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Parameters
|
||||
{
|
||||
Code fwd;
|
||||
@ -295,6 +308,21 @@ u32 gen_sanity()
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Template
|
||||
{
|
||||
Code t_Type = def_type( name(Type) );
|
||||
|
||||
Code tmpl = def_template( def_param( t_class, name(Type) )
|
||||
, def_function( name(test_template), def_param( t_Type, name(a) ), __
|
||||
, def_function_body(1, def_comment( StrC::from("Empty template function body")))
|
||||
)
|
||||
);
|
||||
|
||||
gen_sanity_file.print(tmpl);
|
||||
}
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
gen_sanity_file.print( def_comment( StrC::from(
|
||||
"End of base case tests.\n"
|
||||
)));
|
||||
|
@ -251,7 +251,7 @@ void gen__array_request( StrC type, sw size, StrC dep = {} )
|
||||
GenArrayRequest request = { dep, type, size };
|
||||
array_append( GenArrayRequests, request );
|
||||
}
|
||||
#define gen_array( type ) gen__array_request( { txt_n_len(type) }, sizeof(type) )
|
||||
#define gen_array( type ) gen__array_request( { txt_to_StrC(type) }, sizeof(type) )
|
||||
|
||||
u32 gen_array_file()
|
||||
{
|
||||
|
@ -142,7 +142,6 @@ u32 gen_sanity()
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Operator
|
||||
if (0)
|
||||
{
|
||||
Code bitflagtest = parse_enum( code(
|
||||
enum class EBitFlagTest : u8
|
||||
@ -171,6 +170,25 @@ u32 gen_sanity()
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Operator cast
|
||||
{
|
||||
Code op_ptr = parse_operator_cast( code(
|
||||
operator u8* ();
|
||||
));
|
||||
|
||||
Code class_def = parse_class( code(
|
||||
class TestClass
|
||||
{
|
||||
};
|
||||
));
|
||||
|
||||
class_def.body()->add_entry( op_ptr );
|
||||
|
||||
gen_sanity_file.print(class_def);
|
||||
}
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Parameters
|
||||
{
|
||||
Code fwd = parse_function( code(
|
||||
@ -209,7 +227,6 @@ u32 gen_sanity()
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Struct
|
||||
if (0)
|
||||
{
|
||||
Code fwd = parse_struct( code(
|
||||
struct TestEmptyStruct;
|
||||
@ -229,7 +246,6 @@ u32 gen_sanity()
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Union
|
||||
if (0)
|
||||
{
|
||||
Code empty = parse_union( code(
|
||||
union TestEmptyUnion
|
||||
@ -239,10 +255,13 @@ u32 gen_sanity()
|
||||
|
||||
empty.body()->add_entry( def_comment( StrC::from("Empty union body") ) );
|
||||
|
||||
gen_sanity_file.print( parse_typedef( code( typedef unsigned short u16; )) );
|
||||
gen_sanity_file.print( parse_typedef( code( typedef unsigned long u32; )) );
|
||||
|
||||
Code def = parse_union( code(
|
||||
union TestUnion
|
||||
{
|
||||
u8 a;
|
||||
u8 a;
|
||||
u16 b;
|
||||
u32 c;
|
||||
};
|
||||
@ -255,28 +274,30 @@ u32 gen_sanity()
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Using
|
||||
if (0)
|
||||
{
|
||||
Code reg = parse_using( code(
|
||||
using TestUsing = u8;
|
||||
));
|
||||
|
||||
Code nspace = parse_using( code(
|
||||
Code nspace = parse_namespace( code(
|
||||
namespace TestNamespace
|
||||
{
|
||||
};
|
||||
|
||||
using namespace TestUsing;
|
||||
));
|
||||
|
||||
Code npspace_using = parse_using( code(
|
||||
using namespace TestNamespace;
|
||||
));
|
||||
|
||||
gen_sanity_file.print(reg);
|
||||
gen_sanity_file.print(nspace);
|
||||
gen_sanity_file.print(npspace_using);
|
||||
}
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// Variable
|
||||
if (0)
|
||||
{
|
||||
Code bss = parse_variable( code(
|
||||
u8 test_variable;
|
||||
@ -285,6 +306,26 @@ u32 gen_sanity()
|
||||
Code data = parse_variable( code(
|
||||
u8 test_variable = 0x12;
|
||||
));
|
||||
|
||||
gen_sanity_file.print(bss);
|
||||
gen_sanity_file.print(data);
|
||||
}
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
||||
// template
|
||||
{
|
||||
#pragma push_macro("template")
|
||||
#undef template
|
||||
Code tmpl = parse_template( code(
|
||||
template< typename Type >
|
||||
void test_template( Type a )
|
||||
{
|
||||
}
|
||||
));
|
||||
#pragma pop_macro("template")
|
||||
|
||||
gen_sanity_file.print(tmpl);
|
||||
}
|
||||
|
||||
gen_sanity_file.print_fmt("\n");
|
||||
|
@ -17,7 +17,7 @@ int gen_main()
|
||||
Memory::setup();
|
||||
gen::init();
|
||||
|
||||
// gen_sanity();
|
||||
gen_sanity();
|
||||
|
||||
gen_array( u8 );
|
||||
// gen_array( sw );
|
||||
|
102
thirdparty/zpl.h
vendored
102
thirdparty/zpl.h
vendored
@ -3141,10 +3141,10 @@ ZPL_BEGIN_C_DECLS
|
||||
|
||||
typedef enum AllocType
|
||||
{
|
||||
EAllocationALLOC,
|
||||
EAllocationFREE,
|
||||
EAllocationFREE_ALL,
|
||||
EAllocationRESIZE,
|
||||
EAllocation_ALLOC,
|
||||
EAllocation_FREE,
|
||||
EAllocation_FREE_ALL,
|
||||
EAllocation_RESIZE,
|
||||
} AllocType;
|
||||
|
||||
// NOTE: This is useful so you can define an allocator of the same type and parameters
|
||||
@ -3392,7 +3392,7 @@ ZPL_DEF ZPL_ALLOCATOR_PROC( stack_allocator_proc );
|
||||
|
||||
ZPL_IMPL_INLINE void* alloc_align( AllocatorInfo a, sw size, sw alignment )
|
||||
{
|
||||
return a.proc( a.data, EAllocationALLOC, size, alignment, NULL, 0, ZPL_DEFAULT_ALLOCATOR_FLAGS );
|
||||
return a.proc( a.data, EAllocation_ALLOC, size, alignment, NULL, 0, ZPL_DEFAULT_ALLOCATOR_FLAGS );
|
||||
}
|
||||
|
||||
ZPL_IMPL_INLINE void* alloc( AllocatorInfo a, sw size )
|
||||
@ -3403,12 +3403,12 @@ ZPL_IMPL_INLINE void* alloc( AllocatorInfo a, sw size )
|
||||
ZPL_IMPL_INLINE void free( AllocatorInfo a, void* ptr )
|
||||
{
|
||||
if ( ptr != NULL )
|
||||
a.proc( a.data, EAllocationFREE, 0, 0, ptr, 0, ZPL_DEFAULT_ALLOCATOR_FLAGS );
|
||||
a.proc( a.data, EAllocation_FREE, 0, 0, ptr, 0, ZPL_DEFAULT_ALLOCATOR_FLAGS );
|
||||
}
|
||||
|
||||
ZPL_IMPL_INLINE void free_all( AllocatorInfo a )
|
||||
{
|
||||
a.proc( a.data, EAllocationFREE_ALL, 0, 0, NULL, 0, ZPL_DEFAULT_ALLOCATOR_FLAGS );
|
||||
a.proc( a.data, EAllocation_FREE_ALL, 0, 0, NULL, 0, ZPL_DEFAULT_ALLOCATOR_FLAGS );
|
||||
}
|
||||
|
||||
ZPL_IMPL_INLINE void* resize( AllocatorInfo a, void* ptr, sw old_size, sw new_size )
|
||||
@ -3418,7 +3418,7 @@ ZPL_IMPL_INLINE void* resize( AllocatorInfo a, void* ptr, sw old_size, sw new_si
|
||||
|
||||
ZPL_IMPL_INLINE void* resize_align( AllocatorInfo a, void* ptr, sw old_size, sw new_size, sw alignment )
|
||||
{
|
||||
return a.proc( a.data, EAllocationRESIZE, new_size, alignment, ptr, old_size, ZPL_DEFAULT_ALLOCATOR_FLAGS );
|
||||
return a.proc( a.data, EAllocation_RESIZE, new_size, alignment, ptr, old_size, ZPL_DEFAULT_ALLOCATOR_FLAGS );
|
||||
}
|
||||
|
||||
ZPL_IMPL_INLINE void* alloc_copy( AllocatorInfo a, void const* src, sw size )
|
||||
@ -4025,12 +4025,12 @@ typedef struct BufferHeader
|
||||
buffer_count( x ) += ( item_count ); \
|
||||
} while ( 0 )
|
||||
|
||||
#define buffer_copy_init( y, x ) \
|
||||
do \
|
||||
{ \
|
||||
buffer_init( y, buffer_allocator( x ), buffer_capacity( x ) ); \
|
||||
ZPL_NS( mem_copy )( y, x, buffer_capacity( x ) * size_of( *x ) ); \
|
||||
buffer_count( y ) = buffer_count( x ); \
|
||||
#define buffer_copy_init( y, x ) \
|
||||
do \
|
||||
{ \
|
||||
ZPL_NS( buffer_init )( y, ZPL_NS( buffer_allocator )( x ), buffer_capacity( x ) ); \
|
||||
ZPL_NS( mem_copy )( y, x, buffer_capacity( x ) * size_of( *x ) ); \
|
||||
buffer_count( y ) = buffer_count( x ); \
|
||||
} while ( 0 )
|
||||
|
||||
#define buffer_pop( x ) \
|
||||
@ -8324,10 +8324,10 @@ ZPL_BEGIN_C_DECLS
|
||||
|
||||
typedef enum CSV_Error
|
||||
{
|
||||
ECSV_Error_NONE,
|
||||
ECSV_Error_INTERNAL,
|
||||
ECSV_Error_UNEXPECTED_END_OF_INPUT,
|
||||
ECSV_Error_MISMATCHED_ROWS,
|
||||
ECSV_Error__NONE,
|
||||
ECSV_Error__INTERNAL,
|
||||
ECSV_Error__UNEXPECTED_END_OF_INPUT,
|
||||
ECSV_Error__MISMATCHED_ROWS,
|
||||
} CSV_Error;
|
||||
|
||||
typedef ADT_Node CSV_Object;
|
||||
@ -9302,7 +9302,7 @@ ZPL_ALLOCATOR_PROC( heap_allocator_proc )
|
||||
sw track_size = max( alloc_info_size, alignment ) + alloc_info_remainder;
|
||||
switch ( type )
|
||||
{
|
||||
case EAllocationFREE :
|
||||
case EAllocation_FREE :
|
||||
{
|
||||
if ( ! old_memory )
|
||||
break;
|
||||
@ -9312,7 +9312,7 @@ ZPL_ALLOCATOR_PROC( heap_allocator_proc )
|
||||
old_memory = alloc_info->physical_start;
|
||||
}
|
||||
break;
|
||||
case EAllocationALLOC :
|
||||
case EAllocation_ALLOC :
|
||||
{
|
||||
size += track_size;
|
||||
}
|
||||
@ -9325,15 +9325,15 @@ ZPL_ALLOCATOR_PROC( heap_allocator_proc )
|
||||
switch ( type )
|
||||
{
|
||||
#if defined( ZPL_COMPILER_MSVC ) || ( defined( ZPL_COMPILER_GCC ) && defined( ZPL_SYSTEM_WINDOWS ) ) || ( defined( ZPL_COMPILER_TINYC ) && defined( ZPL_SYSTEM_WINDOWS ) )
|
||||
case EAllocationALLOC :
|
||||
case EAllocation_ALLOC :
|
||||
ptr = _aligned_malloc( size, alignment );
|
||||
if ( flags & ZPL_ALLOCATOR_FLAG_CLEAR_TO_ZERO )
|
||||
zero_size( ptr, size );
|
||||
break;
|
||||
case EAllocationFREE :
|
||||
case EAllocation_FREE :
|
||||
_aligned_free( old_memory );
|
||||
break;
|
||||
case EAllocationRESIZE :
|
||||
case EAllocation_RESIZE :
|
||||
{
|
||||
AllocatorInfo a = heap_allocator();
|
||||
ptr = default_resize_align( a, old_memory, old_size, size, alignment );
|
||||
@ -9341,7 +9341,7 @@ ZPL_ALLOCATOR_PROC( heap_allocator_proc )
|
||||
break;
|
||||
|
||||
#elif defined( ZPL_SYSTEM_LINUX ) && ! defined( ZPL_CPU_ARM ) && ! defined( ZPL_COMPILER_TINYC )
|
||||
case EAllocationALLOC :
|
||||
case EAllocation_ALLOC :
|
||||
{
|
||||
ptr = aligned_alloc( alignment, ( size + alignment - 1 ) & ~( alignment - 1 ) );
|
||||
|
||||
@ -9352,20 +9352,20 @@ ZPL_ALLOCATOR_PROC( heap_allocator_proc )
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocationFREE :
|
||||
case EAllocation_FREE :
|
||||
{
|
||||
free( old_memory );
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocationRESIZE :
|
||||
case EAllocation_RESIZE :
|
||||
{
|
||||
AllocatorInfo a = heap_allocator();
|
||||
ptr = default_resize_align( a, old_memory, old_size, size, alignment );
|
||||
}
|
||||
break;
|
||||
#else
|
||||
case EAllocationALLOC :
|
||||
case EAllocation_ALLOC :
|
||||
{
|
||||
posix_memalign( &ptr, alignment, size );
|
||||
|
||||
@ -9376,13 +9376,13 @@ ZPL_ALLOCATOR_PROC( heap_allocator_proc )
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocationFREE :
|
||||
case EAllocation_FREE :
|
||||
{
|
||||
free( old_memory );
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocationRESIZE :
|
||||
case EAllocation_RESIZE :
|
||||
{
|
||||
AllocatorInfo a = heap_allocator();
|
||||
ptr = default_resize_align( a, old_memory, old_size, size, alignment );
|
||||
@ -9390,12 +9390,12 @@ ZPL_ALLOCATOR_PROC( heap_allocator_proc )
|
||||
break;
|
||||
#endif
|
||||
|
||||
case EAllocationFREE_ALL :
|
||||
case EAllocation_FREE_ALL :
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef ZPL_HEAP_ANALYSIS
|
||||
if ( type == EAllocationALLOC )
|
||||
if ( type == EAllocation_ALLOC )
|
||||
{
|
||||
_heap_alloc_info* alloc_info = zpl_cast( _heap_alloc_info* )( zpl_cast( char* ) ptr + alloc_info_remainder );
|
||||
zero_item( alloc_info );
|
||||
@ -9423,7 +9423,7 @@ ZPL_ALLOCATOR_PROC( arena_allocator_proc )
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case EAllocationALLOC :
|
||||
case EAllocation_ALLOC :
|
||||
{
|
||||
void* end = pointer_add( arena->physical_start, arena->total_allocated );
|
||||
sw total_size = align_forward_i64( size, alignment );
|
||||
@ -9442,16 +9442,16 @@ ZPL_ALLOCATOR_PROC( arena_allocator_proc )
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocationFREE :
|
||||
case EAllocation_FREE :
|
||||
// NOTE: Free all at once
|
||||
// Use Temp_Arena_Memory if you want to free a block
|
||||
break;
|
||||
|
||||
case EAllocationFREE_ALL :
|
||||
case EAllocation_FREE_ALL :
|
||||
arena->total_allocated = 0;
|
||||
break;
|
||||
|
||||
case EAllocationRESIZE :
|
||||
case EAllocation_RESIZE :
|
||||
{
|
||||
// TODO: Check if ptr is on top of stack and just extend
|
||||
AllocatorInfo a = arena_allocator( arena );
|
||||
@ -9509,7 +9509,7 @@ ZPL_ALLOCATOR_PROC( pool_allocator_proc )
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case EAllocationALLOC :
|
||||
case EAllocation_ALLOC :
|
||||
{
|
||||
uptr next_free;
|
||||
ZPL_ASSERT( size == pool->block_size );
|
||||
@ -9525,7 +9525,7 @@ ZPL_ALLOCATOR_PROC( pool_allocator_proc )
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocationFREE :
|
||||
case EAllocation_FREE :
|
||||
{
|
||||
uptr* next;
|
||||
if ( old_memory == NULL )
|
||||
@ -9538,7 +9538,7 @@ ZPL_ALLOCATOR_PROC( pool_allocator_proc )
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocationFREE_ALL :
|
||||
case EAllocation_FREE_ALL :
|
||||
{
|
||||
sw actual_block_size, block_index;
|
||||
void* curr;
|
||||
@ -9562,7 +9562,7 @@ ZPL_ALLOCATOR_PROC( pool_allocator_proc )
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocationRESIZE :
|
||||
case EAllocation_RESIZE :
|
||||
// NOTE: Cannot resize
|
||||
ZPL_PANIC( "You cannot resize something allocated by with a pool." );
|
||||
break;
|
||||
@ -9608,7 +9608,7 @@ ZPL_ALLOCATOR_PROC( scratch_allocator_proc )
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case EAllocationALLOC :
|
||||
case EAllocation_ALLOC :
|
||||
{
|
||||
void* pt = s->alloc_point;
|
||||
allocation_header_ev* header = zpl_cast( allocation_header_ev* ) pt;
|
||||
@ -9641,7 +9641,7 @@ ZPL_ALLOCATOR_PROC( scratch_allocator_proc )
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocationFREE :
|
||||
case EAllocation_FREE :
|
||||
{
|
||||
if ( old_memory )
|
||||
{
|
||||
@ -9672,12 +9672,12 @@ ZPL_ALLOCATOR_PROC( scratch_allocator_proc )
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocationFREE_ALL :
|
||||
case EAllocation_FREE_ALL :
|
||||
s->alloc_point = s->physical_start;
|
||||
s->free_point = s->physical_start;
|
||||
break;
|
||||
|
||||
case EAllocationRESIZE :
|
||||
case EAllocation_RESIZE :
|
||||
ptr = default_resize_align( scratch_allocator( s ), old_memory, old_size, size, alignment );
|
||||
break;
|
||||
}
|
||||
@ -9698,7 +9698,7 @@ ZPL_ALLOCATOR_PROC( stack_allocator_proc )
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case EAllocationALLOC :
|
||||
case EAllocation_ALLOC :
|
||||
{
|
||||
size += ZPL_STACK_ALLOC_OFFSET;
|
||||
u64 alloc_offset = s->allocated;
|
||||
@ -9729,7 +9729,7 @@ ZPL_ALLOCATOR_PROC( stack_allocator_proc )
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocationFREE :
|
||||
case EAllocation_FREE :
|
||||
{
|
||||
if ( old_memory )
|
||||
{
|
||||
@ -9742,13 +9742,13 @@ ZPL_ALLOCATOR_PROC( stack_allocator_proc )
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocationFREE_ALL :
|
||||
case EAllocation_FREE_ALL :
|
||||
{
|
||||
s->allocated = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case EAllocationRESIZE :
|
||||
case EAllocation_RESIZE :
|
||||
{
|
||||
ZPL_PANIC( "You cannot resize something allocated by a stack." );
|
||||
}
|
||||
@ -21338,7 +21338,7 @@ ZPL_BEGIN_C_DECLS
|
||||
|
||||
u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b32 has_header, char delim )
|
||||
{
|
||||
CSV_Error err = ECSV_Error_NONE;
|
||||
CSV_Error err = ECSV_Error__NONE;
|
||||
ZPL_ASSERT_NOT_NULL( root );
|
||||
ZPL_ASSERT_NOT_NULL( text );
|
||||
zero_item( root );
|
||||
@ -21379,7 +21379,7 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
||||
if ( *e == 0 )
|
||||
{
|
||||
ZPL_CSV_ASSERT( "unmatched quoted string" );
|
||||
err = ECSV_Error_UNEXPECTED_END_OF_INPUT;
|
||||
err = ECSV_Error__UNEXPECTED_END_OF_INPUT;
|
||||
return err;
|
||||
}
|
||||
*e = 0;
|
||||
@ -21467,7 +21467,7 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
||||
else if ( total_colc != colc )
|
||||
{
|
||||
ZPL_CSV_ASSERT( "mismatched rows" );
|
||||
err = ECSV_Error_MISMATCHED_ROWS;
|
||||
err = ECSV_Error__MISMATCHED_ROWS;
|
||||
return err;
|
||||
}
|
||||
colc = 0;
|
||||
@ -21479,7 +21479,7 @@ u8 csv_parse_delimiter( CSV_Object* root, char* text, AllocatorInfo allocator, b
|
||||
if ( array_count( root->nodes ) == 0 )
|
||||
{
|
||||
ZPL_CSV_ASSERT( "unexpected end of input. stream is empty." );
|
||||
err = ECSV_Error_UNEXPECTED_END_OF_INPUT;
|
||||
err = ECSV_Error__UNEXPECTED_END_OF_INPUT;
|
||||
return err;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user