cinera: Remove memory_book_type
This commit is contained in:
parent
9cdb3b96d9
commit
63ab9d5bc2
200
cinera/cinera.c
200
cinera/cinera.c
|
@ -23,7 +23,7 @@ typedef struct
|
||||||
version CINERA_APP_VERSION = {
|
version CINERA_APP_VERSION = {
|
||||||
.Major = 0,
|
.Major = 0,
|
||||||
.Minor = 8,
|
.Minor = 8,
|
||||||
.Patch = 13
|
.Patch = 15
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <stdarg.h> // NOTE(matt): varargs
|
#include <stdarg.h> // NOTE(matt): varargs
|
||||||
|
@ -492,50 +492,6 @@ typedef struct memory_pen_location
|
||||||
struct memory_pen_location *Next;
|
struct memory_pen_location *Next;
|
||||||
} memory_pen_location;
|
} memory_pen_location;
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
MBT_NONE,
|
|
||||||
|
|
||||||
MBT_ASSET,
|
|
||||||
MBT_CATEGORY_INFO,
|
|
||||||
MBT_CONFIG_IDENTIFIER_ID,
|
|
||||||
MBT_CONFIG_BOOL_PAIR,
|
|
||||||
MBT_CONFIG_INT_PAIR,
|
|
||||||
MBT_CONFIG_PAIR,
|
|
||||||
MBT_CONFIG_STRING_ASSOCIATION,
|
|
||||||
MBT_CONFIG_TYPE_FIELD,
|
|
||||||
MBT_CONFIG_TYPE_SPEC,
|
|
||||||
MBT_CREDIT,
|
|
||||||
MBT_IDENTIFIER,
|
|
||||||
MBT_LANDMARK,
|
|
||||||
MBT_MEDIUM,
|
|
||||||
MBT_NAVIGATION_BUFFER,
|
|
||||||
MBT_PERSON,
|
|
||||||
MBT_PERSON_PTR,
|
|
||||||
MBT_PROJECT,
|
|
||||||
MBT_PROJECT_PTR,
|
|
||||||
MBT_REF_INFO,
|
|
||||||
MBT_RESOLUTION_ERROR,
|
|
||||||
MBT_ROLE,
|
|
||||||
MBT_SCOPE_TREE,
|
|
||||||
MBT_SCOPE_TREE_PTR,
|
|
||||||
MBT_SPEAKER,
|
|
||||||
MBT_STRING,
|
|
||||||
MBT_STRING_PTR,
|
|
||||||
MBT_SUPPORT,
|
|
||||||
MBT_TAG_OFFSET,
|
|
||||||
MBT_TOKEN,
|
|
||||||
MBT_TOKENS,
|
|
||||||
MBT_UINT32,
|
|
||||||
MBT_VARIANT,
|
|
||||||
MBT_VARIANT_STRING,
|
|
||||||
MBT_WATCH_FILE,
|
|
||||||
MBT_WATCH_HANDLE,
|
|
||||||
MBT_COUNT,
|
|
||||||
} memory_book_type;
|
|
||||||
|
|
||||||
uint64_t MemoryBookTypeWidths[MBT_COUNT];
|
|
||||||
|
|
||||||
// TODO(matt): We probably want our memory_book to be able to support strings that span multiple pages
|
// TODO(matt): We probably want our memory_book to be able to support strings that span multiple pages
|
||||||
// SearchQuotes() especially could benefit from this
|
// SearchQuotes() especially could benefit from this
|
||||||
|
|
||||||
|
@ -547,28 +503,23 @@ typedef struct
|
||||||
uint64_t ItemCount;
|
uint64_t ItemCount;
|
||||||
memory_page *Pages;
|
memory_page *Pages;
|
||||||
memory_pen_location *Pen;
|
memory_pen_location *Pen;
|
||||||
memory_book_type Type;
|
|
||||||
} memory_book;
|
} memory_book;
|
||||||
#define _memory_book(type) memory_book
|
#define _memory_book(type) memory_book
|
||||||
|
|
||||||
memory_book
|
memory_book
|
||||||
InitBook(memory_book_type Type, uint64_t ItemsPerPage)
|
InitBook(uint64_t DataWidthInBytes, uint64_t ItemsPerPage)
|
||||||
{
|
{
|
||||||
Assert(MemoryBookTypeWidths[Type]);
|
|
||||||
|
|
||||||
memory_book Result = {};
|
memory_book Result = {};
|
||||||
Result.PageSize = ItemsPerPage * MemoryBookTypeWidths[Type];
|
Result.PageSize = ItemsPerPage * DataWidthInBytes;
|
||||||
Result.Type = Type;
|
Result.DataWidthInBytes = DataWidthInBytes;
|
||||||
Result.DataWidthInBytes = MemoryBookTypeWidths[Type];
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
memory_book
|
memory_book
|
||||||
InitBookOfPointers(memory_book_type Type, uint64_t ItemsPerPage)
|
InitBookOfPointers(uint64_t ItemsPerPage)
|
||||||
{
|
{
|
||||||
memory_book Result = {};
|
memory_book Result = {};
|
||||||
Result.PageSize = ItemsPerPage * sizeof(uintptr_t);
|
Result.PageSize = ItemsPerPage * sizeof(uintptr_t);
|
||||||
Result.Type = Type;
|
|
||||||
Result.DataWidthInBytes = sizeof(uintptr_t);
|
Result.DataWidthInBytes = sizeof(uintptr_t);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
@ -578,7 +529,6 @@ InitBookOfStrings(uint64_t PageSizeInBytes)
|
||||||
{
|
{
|
||||||
memory_book Result = {};
|
memory_book Result = {};
|
||||||
Result.PageSize = PageSizeInBytes;
|
Result.PageSize = PageSizeInBytes;
|
||||||
Result.Type = MBT_STRING;
|
|
||||||
Result.DataWidthInBytes = 1;
|
Result.DataWidthInBytes = 1;
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
@ -609,8 +559,6 @@ FreeBook(memory_book *M)
|
||||||
}
|
}
|
||||||
FreeAndResetCount(M->Pages, M->PageCount);
|
FreeAndResetCount(M->Pages, M->PageCount);
|
||||||
|
|
||||||
if(M->Type == MBT_STRING)
|
|
||||||
{
|
|
||||||
memory_pen_location *This = M->Pen;
|
memory_pen_location *This = M->Pen;
|
||||||
while(This)
|
while(This)
|
||||||
{
|
{
|
||||||
|
@ -618,7 +566,6 @@ FreeBook(memory_book *M)
|
||||||
Free(This);
|
Free(This);
|
||||||
This = M->Pen;
|
This = M->Pen;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
memory_book Zero = {};
|
memory_book Zero = {};
|
||||||
*M = Zero;
|
*M = Zero;
|
||||||
|
@ -629,13 +576,11 @@ FreeAndReinitialiseBook(memory_book *M)
|
||||||
{
|
{
|
||||||
int PageSize = M->PageSize;
|
int PageSize = M->PageSize;
|
||||||
int DataWidthInBytes = M->DataWidthInBytes;
|
int DataWidthInBytes = M->DataWidthInBytes;
|
||||||
int Type = M->Type;
|
|
||||||
|
|
||||||
FreeBook(M);
|
FreeBook(M);
|
||||||
|
|
||||||
M->PageSize = PageSize;
|
M->PageSize = PageSize;
|
||||||
M->DataWidthInBytes = DataWidthInBytes;
|
M->DataWidthInBytes = DataWidthInBytes;
|
||||||
M->Type = Type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memory_page *
|
memory_page *
|
||||||
|
@ -810,54 +755,12 @@ PrintPage(memory_page *P)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintBook(memory_book *M)
|
PrintBookOfStrings(memory_book *M)
|
||||||
{
|
{
|
||||||
switch(M->Type)
|
|
||||||
{
|
|
||||||
case MBT_STRING:
|
|
||||||
{
|
|
||||||
for(int i = 0; i < M->PageCount; ++i)
|
for(int i = 0; i < M->PageCount; ++i)
|
||||||
{
|
{
|
||||||
PrintPage(&M->Pages[i]);
|
PrintPage(&M->Pages[i]);
|
||||||
}
|
}
|
||||||
} break;
|
|
||||||
case MBT_NONE: Assert(0); break;
|
|
||||||
case MBT_ASSET: Assert(0); break;
|
|
||||||
case MBT_CATEGORY_INFO: Assert(0); break;
|
|
||||||
case MBT_CONFIG_IDENTIFIER_ID: Assert(0); break;
|
|
||||||
case MBT_CONFIG_BOOL_PAIR: Assert(0); break;
|
|
||||||
case MBT_CONFIG_INT_PAIR: Assert(0); break;
|
|
||||||
case MBT_CONFIG_PAIR: Assert(0); break;
|
|
||||||
case MBT_CONFIG_STRING_ASSOCIATION: Assert(0); break;
|
|
||||||
case MBT_CONFIG_TYPE_FIELD: Assert(0); break;
|
|
||||||
case MBT_CONFIG_TYPE_SPEC: Assert(0); break;
|
|
||||||
case MBT_CREDIT: Assert(0); break;
|
|
||||||
case MBT_IDENTIFIER: Assert(0); break;
|
|
||||||
case MBT_LANDMARK: Assert(0); break;
|
|
||||||
case MBT_MEDIUM: Assert(0); break;
|
|
||||||
case MBT_NAVIGATION_BUFFER: Assert(0); break;
|
|
||||||
case MBT_PERSON: Assert(0); break;
|
|
||||||
case MBT_PERSON_PTR: Assert(0); break;
|
|
||||||
case MBT_PROJECT: Assert(0); break;
|
|
||||||
case MBT_PROJECT_PTR: Assert(0); break;
|
|
||||||
case MBT_REF_INFO: Assert(0); break;
|
|
||||||
case MBT_RESOLUTION_ERROR: Assert(0); break;
|
|
||||||
case MBT_ROLE: Assert(0); break;
|
|
||||||
case MBT_SCOPE_TREE: Assert(0); break;
|
|
||||||
case MBT_SCOPE_TREE_PTR: Assert(0); break;
|
|
||||||
case MBT_SPEAKER: Assert(0); break;
|
|
||||||
case MBT_STRING_PTR: Assert(0); break;
|
|
||||||
case MBT_SUPPORT: Assert(0); break;
|
|
||||||
case MBT_TAG_OFFSET: Assert(0); break;
|
|
||||||
case MBT_TOKEN: Assert(0); break;
|
|
||||||
case MBT_TOKENS: Assert(0); break;
|
|
||||||
case MBT_UINT32: Assert(0); break;
|
|
||||||
case MBT_VARIANT: Assert(0); break;
|
|
||||||
case MBT_VARIANT_STRING: Assert(0); break;
|
|
||||||
case MBT_WATCH_FILE: Assert(0); break;
|
|
||||||
case MBT_WATCH_HANDLE: Assert(0); break;
|
|
||||||
case MBT_COUNT: break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t
|
int64_t
|
||||||
|
@ -4239,8 +4142,8 @@ InitTemplate(template *Template, string Location, template_type Type)
|
||||||
fprintf(stderr, "%sPacking%s template: %s\n", ColourStrings[CS_ONGOING], ColourStrings[CS_END], Template->File.Path);
|
fprintf(stderr, "%sPacking%s template: %s\n", ColourStrings[CS_ONGOING], ColourStrings[CS_END], Template->File.Path);
|
||||||
ReadFileIntoBuffer(&Template->File);
|
ReadFileIntoBuffer(&Template->File);
|
||||||
ClearTemplateMetadata(Template);
|
ClearTemplateMetadata(Template);
|
||||||
Template->Metadata.Tags = InitBook(MBT_TAG_OFFSET, 16);
|
Template->Metadata.Tags = InitBook(sizeof(tag_offset), 16);
|
||||||
Template->Metadata.NavBuffer = InitBook(MBT_NAVIGATION_BUFFER, 4);
|
Template->Metadata.NavBuffer = InitBook(sizeof(navigation_buffer), 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SECONDS_PER_HOUR 3600
|
#define SECONDS_PER_HOUR 3600
|
||||||
|
@ -5640,7 +5543,7 @@ PushWatchHandle(string Path, extension_id Extension, watch_type Type, project *P
|
||||||
if(!Watch)
|
if(!Watch)
|
||||||
{
|
{
|
||||||
Watch = MakeSpaceInBook(&WatchHandles.Handles);
|
Watch = MakeSpaceInBook(&WatchHandles.Handles);
|
||||||
Watch->Files = InitBook(MBT_WATCH_FILE, 16);
|
Watch->Files = InitBook(sizeof(watch_file), 16);
|
||||||
|
|
||||||
Watch->TargetPath = TargetPath;
|
Watch->TargetPath = TargetPath;
|
||||||
Watch->WatchedPath = GetNearestExistingPath(TargetPath);
|
Watch->WatchedPath = GetNearestExistingPath(TargetPath);
|
||||||
|
@ -6021,8 +5924,8 @@ PlaceAsset(string Filename, asset_type Type, uint64_t Variants, bool Associated,
|
||||||
This->FilenameAt = FinalPathComponentPosition(Filename);
|
This->FilenameAt = FinalPathComponentPosition(Filename);
|
||||||
if(Position == Assets.ItemCount && !This->Known)
|
if(Position == Assets.ItemCount && !This->Known)
|
||||||
{
|
{
|
||||||
This->Player = InitBook(MBT_LANDMARK, 8);
|
This->Player = InitBook(sizeof(landmark), 8);
|
||||||
This->Search = InitBook(MBT_LANDMARK, 8);
|
This->Search = InitBook(sizeof(landmark), 8);
|
||||||
++Assets.ItemCount;
|
++Assets.ItemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6105,7 +6008,7 @@ InitBuiltinAssets(void)
|
||||||
void
|
void
|
||||||
InitAssets(void)
|
InitAssets(void)
|
||||||
{
|
{
|
||||||
Assets = InitBook(MBT_ASSET, 16);
|
Assets = InitBook(sizeof(asset), 16);
|
||||||
InitBuiltinAssets();
|
InitBuiltinAssets();
|
||||||
db_block_assets *AssetsBlock = LocateBlock(B_ASET);
|
db_block_assets *AssetsBlock = LocateBlock(B_ASET);
|
||||||
if(AssetsBlock)
|
if(AssetsBlock)
|
||||||
|
@ -6957,7 +6860,7 @@ BuildCredits(string HMMLFilepath, buffer *CreditsMenu, HMML_VideoMetaData *Metad
|
||||||
speakers *Speakers, bool *RequiresCineraJS)
|
speakers *Speakers, bool *RequiresCineraJS)
|
||||||
{
|
{
|
||||||
#if(HMMLIB_MAJOR_VERSION == 2)
|
#if(HMMLIB_MAJOR_VERSION == 2)
|
||||||
memory_book Credits = InitBook(MBT_CREDIT, 4);
|
memory_book Credits = InitBook(sizeof(credit), 4);
|
||||||
MergeCredits(&Credits, CurrentProject, Metadata);
|
MergeCredits(&Credits, CurrentProject, Metadata);
|
||||||
for(int RoleIndex = 0; RoleIndex < Config->Role.ItemCount; ++RoleIndex)
|
for(int RoleIndex = 0; RoleIndex < Config->Role.ItemCount; ++RoleIndex)
|
||||||
{
|
{
|
||||||
|
@ -9508,7 +9411,7 @@ speakers
|
||||||
InitSpeakers()
|
InitSpeakers()
|
||||||
{
|
{
|
||||||
speakers Result = {};
|
speakers Result = {};
|
||||||
Result.Speakers = InitBook(MBT_SPEAKER, 4);
|
Result.Speakers = InitBook(sizeof(speaker), 4);
|
||||||
Result.Abbreviations = InitBookOfStrings(64);
|
Result.Abbreviations = InitBookOfStrings(64);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
@ -9577,7 +9480,7 @@ BuildReference(memory_book *Strings, _memory_book(ref_info) *ReferencesArray, HM
|
||||||
if(ID)
|
if(ID)
|
||||||
{
|
{
|
||||||
ref_info *This = MakeSpaceInBook(ReferencesArray);
|
ref_info *This = MakeSpaceInBook(ReferencesArray);
|
||||||
This->Identifier = InitBook(MBT_IDENTIFIER, 4);
|
This->Identifier = InitBook(sizeof(identifier), 4);
|
||||||
// TODO(matt): Just point into the Ref directly, rather than copying strings?
|
// TODO(matt): Just point into the Ref directly, rather than copying strings?
|
||||||
if(Ref->isbn)
|
if(Ref->isbn)
|
||||||
{
|
{
|
||||||
|
@ -9792,8 +9695,8 @@ ProcessTimestamp(buffers *CollationBuffers, neighbourhood *N, string Filepath, m
|
||||||
*PreviousTimecode = Timestamp->time;
|
*PreviousTimecode = Timestamp->time;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
memory_book LocalTopics = InitBook(MBT_CATEGORY_INFO, 8);
|
memory_book LocalTopics = InitBook(sizeof(category_info), 8);
|
||||||
memory_book LocalMedia = InitBook(MBT_CATEGORY_INFO, 8);
|
memory_book LocalMedia = InitBook(sizeof(category_info), 8);
|
||||||
|
|
||||||
quote_info QuoteInfo = { };
|
quote_info QuoteInfo = { };
|
||||||
|
|
||||||
|
@ -10612,10 +10515,10 @@ HMMLToBuffers(buffers *CollationBuffers, template *BespokeTemplate, string BaseF
|
||||||
if(ClaimMenuIndexAndPlayerBuffers(&MenuBuffers, &IndexBuffers, &PlayerBuffers) == RC_SUCCESS)
|
if(ClaimMenuIndexAndPlayerBuffers(&MenuBuffers, &IndexBuffers, &PlayerBuffers) == RC_SUCCESS)
|
||||||
{
|
{
|
||||||
memory_book Strings = InitBookOfStrings(Kilobytes(4));
|
memory_book Strings = InitBookOfStrings(Kilobytes(4));
|
||||||
_memory_book(ref_info) ReferencesArray = InitBook(MBT_REF_INFO, 8);
|
_memory_book(ref_info) ReferencesArray = InitBook(sizeof(ref_info), 8);
|
||||||
speakers Speakers = InitSpeakers();
|
speakers Speakers = InitSpeakers();
|
||||||
memory_book Topics = InitBook(MBT_CATEGORY_INFO, 8);
|
memory_book Topics = InitBook(sizeof(category_info), 8);
|
||||||
memory_book Media = InitBook(MBT_CATEGORY_INFO, 8);
|
memory_book Media = InitBook(sizeof(category_info), 8);
|
||||||
|
|
||||||
bool HasQuoteMenu = FALSE;
|
bool HasQuoteMenu = FALSE;
|
||||||
bool HasReferenceMenu = FALSE;
|
bool HasReferenceMenu = FALSE;
|
||||||
|
@ -13851,7 +13754,7 @@ PushUniqueString(memory_book *UniqueThemes, string *GlobalTheme)
|
||||||
void
|
void
|
||||||
GenerateThemeLinks(buffer *IncludesSearch, project *P)
|
GenerateThemeLinks(buffer *IncludesSearch, project *P)
|
||||||
{
|
{
|
||||||
memory_book UniqueThemes = InitBookOfPointers(MBT_STRING_PTR, 4);
|
memory_book UniqueThemes = InitBookOfPointers(4);
|
||||||
if(P)
|
if(P)
|
||||||
{
|
{
|
||||||
PushUniqueStringsRecursively(&UniqueThemes, P);
|
PushUniqueStringsRecursively(&UniqueThemes, P);
|
||||||
|
@ -15071,7 +14974,7 @@ project_generations
|
||||||
CopyAccumulator(project_generations *G)
|
CopyAccumulator(project_generations *G)
|
||||||
{
|
{
|
||||||
project_generations Result = {};
|
project_generations Result = {};
|
||||||
Result.EntriesInGeneration = InitBook(MBT_UINT32, 4);
|
Result.EntriesInGeneration = InitBook(sizeof(uint32_t), 4);
|
||||||
for(int i = 0; i < G->EntriesInGeneration.ItemCount; ++i)
|
for(int i = 0; i < G->EntriesInGeneration.ItemCount; ++i)
|
||||||
{
|
{
|
||||||
uint32_t *Src = GetPlaceInBook(&G->EntriesInGeneration, i);
|
uint32_t *Src = GetPlaceInBook(&G->EntriesInGeneration, i);
|
||||||
|
@ -15085,7 +14988,7 @@ project_generations
|
||||||
InitAccumulator(project_generations *G)
|
InitAccumulator(project_generations *G)
|
||||||
{
|
{
|
||||||
project_generations Result = {};
|
project_generations Result = {};
|
||||||
Result.EntriesInGeneration = InitBook(MBT_UINT32, 4);
|
Result.EntriesInGeneration = InitBook(sizeof(uint32_t), 4);
|
||||||
for(int i = 0; i < G->CurrentGeneration; ++i)
|
for(int i = 0; i < G->CurrentGeneration; ++i)
|
||||||
{
|
{
|
||||||
MakeSpaceInBook(&Result.EntriesInGeneration);
|
MakeSpaceInBook(&Result.EntriesInGeneration);
|
||||||
|
@ -15990,7 +15893,7 @@ SyncDB(config *C)
|
||||||
//
|
//
|
||||||
DB.Metadata.Signposts.ProjectsBlock.Ptr = LocateBlock(B_PROJ);
|
DB.Metadata.Signposts.ProjectsBlock.Ptr = LocateBlock(B_PROJ);
|
||||||
project_generations Accumulator = {};
|
project_generations Accumulator = {};
|
||||||
Accumulator.EntriesInGeneration = InitBook(MBT_UINT32, 4);
|
Accumulator.EntriesInGeneration = InitBook(sizeof(uint32_t), 4);
|
||||||
|
|
||||||
db_block_projects *SParent = DB.Metadata.Signposts.ProjectsBlock.Ptr;
|
db_block_projects *SParent = DB.Metadata.Signposts.ProjectsBlock.Ptr;
|
||||||
|
|
||||||
|
@ -16655,59 +16558,10 @@ void
|
||||||
InitWatchHandles(uint32_t DefaultEventsMask, uint64_t DesiredPageSize)
|
InitWatchHandles(uint32_t DefaultEventsMask, uint64_t DesiredPageSize)
|
||||||
{
|
{
|
||||||
WatchHandles.DefaultEventsMask = DefaultEventsMask;
|
WatchHandles.DefaultEventsMask = DefaultEventsMask;
|
||||||
WatchHandles.Handles = InitBook(MBT_WATCH_HANDLE, 16);
|
WatchHandles.Handles = InitBook(sizeof(watch_handle), 16);
|
||||||
WatchHandles.Paths = InitBookOfStrings(DesiredPageSize);
|
WatchHandles.Paths = InitBookOfStrings(DesiredPageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
InitMemoryBookTypeWidths(void)
|
|
||||||
{
|
|
||||||
for(memory_book_type i = 0; i < MBT_COUNT; ++i)
|
|
||||||
{
|
|
||||||
switch(i)
|
|
||||||
{
|
|
||||||
case MBT_ASSET: MemoryBookTypeWidths[i] = sizeof(asset); break;
|
|
||||||
case MBT_CATEGORY_INFO: MemoryBookTypeWidths[i] = sizeof(category_info); break;
|
|
||||||
case MBT_CONFIG_IDENTIFIER_ID: MemoryBookTypeWidths[i] = sizeof(config_identifier_id); break;
|
|
||||||
case MBT_CONFIG_BOOL_PAIR: MemoryBookTypeWidths[i] = sizeof(config_bool_pair); break;
|
|
||||||
case MBT_CONFIG_INT_PAIR: MemoryBookTypeWidths[i] = sizeof(config_int_pair); break;
|
|
||||||
case MBT_CONFIG_PAIR: MemoryBookTypeWidths[i] = sizeof(config_pair); break;
|
|
||||||
case MBT_CONFIG_STRING_ASSOCIATION: MemoryBookTypeWidths[i] = sizeof(config_string_association); break;
|
|
||||||
case MBT_CONFIG_TYPE_FIELD: MemoryBookTypeWidths[i] = sizeof(config_type_field); break;
|
|
||||||
case MBT_CONFIG_TYPE_SPEC: MemoryBookTypeWidths[i] = sizeof(config_type_spec); break;
|
|
||||||
case MBT_CREDIT: MemoryBookTypeWidths[i] = sizeof(credit); break;
|
|
||||||
case MBT_IDENTIFIER: MemoryBookTypeWidths[i] = sizeof(identifier); break;
|
|
||||||
case MBT_LANDMARK: MemoryBookTypeWidths[i] = sizeof(landmark); break;
|
|
||||||
case MBT_MEDIUM: MemoryBookTypeWidths[i] = sizeof(medium); break;
|
|
||||||
case MBT_NAVIGATION_BUFFER: MemoryBookTypeWidths[i] = sizeof(navigation_buffer); break;
|
|
||||||
case MBT_PERSON: MemoryBookTypeWidths[i] = sizeof(person); break;
|
|
||||||
case MBT_PROJECT: MemoryBookTypeWidths[i] = sizeof(project); break;
|
|
||||||
case MBT_REF_INFO: MemoryBookTypeWidths[i] = sizeof(ref_info); break;
|
|
||||||
case MBT_RESOLUTION_ERROR: MemoryBookTypeWidths[i] = sizeof(resolution_error); break;
|
|
||||||
case MBT_ROLE: MemoryBookTypeWidths[i] = sizeof(role); break;
|
|
||||||
case MBT_SCOPE_TREE: MemoryBookTypeWidths[i] = sizeof(scope_tree); break;
|
|
||||||
case MBT_SPEAKER: MemoryBookTypeWidths[i] = sizeof(speaker); break;
|
|
||||||
case MBT_SUPPORT: MemoryBookTypeWidths[i] = sizeof(support); break;
|
|
||||||
case MBT_TAG_OFFSET: MemoryBookTypeWidths[i] = sizeof(tag_offset); break;
|
|
||||||
case MBT_TOKEN: MemoryBookTypeWidths[i] = sizeof(token); break;
|
|
||||||
case MBT_TOKENS: MemoryBookTypeWidths[i] = sizeof(tokens); break;
|
|
||||||
case MBT_UINT32: MemoryBookTypeWidths[i] = sizeof(uint32_t); break;
|
|
||||||
case MBT_VARIANT: MemoryBookTypeWidths[i] = sizeof(variant); break;
|
|
||||||
case MBT_VARIANT_STRING: MemoryBookTypeWidths[i] = sizeof(variant_string); break;
|
|
||||||
case MBT_WATCH_FILE: MemoryBookTypeWidths[i] = sizeof(watch_file); break;
|
|
||||||
case MBT_WATCH_HANDLE: MemoryBookTypeWidths[i] = sizeof(watch_handle); break;
|
|
||||||
|
|
||||||
case MBT_NONE:
|
|
||||||
case MBT_PERSON_PTR:
|
|
||||||
case MBT_PROJECT_PTR:
|
|
||||||
case MBT_SCOPE_TREE_PTR:
|
|
||||||
case MBT_STRING:
|
|
||||||
case MBT_STRING_PTR:
|
|
||||||
case MBT_COUNT: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Coda(int Sig)
|
Coda(int Sig)
|
||||||
{
|
{
|
||||||
|
@ -16733,10 +16587,8 @@ main(int ArgC, char **Args)
|
||||||
{
|
{
|
||||||
MEM_TEST_TOP("main()");
|
MEM_TEST_TOP("main()");
|
||||||
InitInterruptHandler();
|
InitInterruptHandler();
|
||||||
Assert(ArrayCount(MemoryBookTypeWidths) == MBT_COUNT);
|
|
||||||
Assert(ArrayCount(BufferIDStrings) == BID_COUNT);
|
Assert(ArrayCount(BufferIDStrings) == BID_COUNT);
|
||||||
Assert(ArrayCount(TemplateTags) == TEMPLATE_TAG_COUNT);
|
Assert(ArrayCount(TemplateTags) == TEMPLATE_TAG_COUNT);
|
||||||
InitMemoryBookTypeWidths();
|
|
||||||
char CommandLineArg;
|
char CommandLineArg;
|
||||||
char *ConfigPath = "$XDG_CONFIG_HOME/cinera/cinera.conf";
|
char *ConfigPath = "$XDG_CONFIG_HOME/cinera/cinera.conf";
|
||||||
while((CommandLineArg = getopt(ArgC, Args, "0c:ehv")) != -1)
|
while((CommandLineArg = getopt(ArgC, Args, "0c:ehv")) != -1)
|
||||||
|
@ -16799,7 +16651,7 @@ main(int ArgC, char **Args)
|
||||||
|
|
||||||
CollationBuffers.Search.ID = BID_COLLATION_BUFFERS_SEARCH; // NOTE(matt): Allocated by SearchToBuffer()
|
CollationBuffers.Search.ID = BID_COLLATION_BUFFERS_SEARCH; // NOTE(matt): Allocated by SearchToBuffer()
|
||||||
|
|
||||||
memory_book TokensList = InitBook(MBT_TOKENS, 8);
|
memory_book TokensList = InitBook(sizeof(tokens), 8);
|
||||||
template BespokeTemplate = {};
|
template BespokeTemplate = {};
|
||||||
neighbourhood Neighbourhood = {};
|
neighbourhood Neighbourhood = {};
|
||||||
|
|
||||||
|
|
|
@ -343,7 +343,7 @@ tokens *
|
||||||
PushTokens(memory_book *TokensList)
|
PushTokens(memory_book *TokensList)
|
||||||
{
|
{
|
||||||
tokens *This = MakeSpaceInBook(TokensList);
|
tokens *This = MakeSpaceInBook(TokensList);
|
||||||
This->Token = InitBook(MBT_TOKEN, 16);
|
This->Token = InitBook(sizeof(token), 16);
|
||||||
This->CurrentLine = 1;
|
This->CurrentLine = 1;
|
||||||
return This;
|
return This;
|
||||||
}
|
}
|
||||||
|
@ -871,7 +871,7 @@ PushTypeSpec(memory_book *TypeSpecs, config_identifier_id ID, bool IsPermeable)
|
||||||
//PrintFunctionName("PushTypeSpec()");
|
//PrintFunctionName("PushTypeSpec()");
|
||||||
config_type_spec *Result = MakeSpaceInBook(TypeSpecs);
|
config_type_spec *Result = MakeSpaceInBook(TypeSpecs);
|
||||||
Result->ID = ID;
|
Result->ID = ID;
|
||||||
Result->Field = InitBook(MBT_CONFIG_TYPE_FIELD, 4);
|
Result->Field = InitBook(sizeof(config_type_field), 4);
|
||||||
Result->Permeable = IsPermeable;
|
Result->Permeable = IsPermeable;
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
@ -891,7 +891,7 @@ _memory_book(config_type_specs)
|
||||||
InitTypeSpecs(void)
|
InitTypeSpecs(void)
|
||||||
{
|
{
|
||||||
//PrintFunctionName("InitTypeSpecs()");
|
//PrintFunctionName("InitTypeSpecs()");
|
||||||
memory_book Result = InitBook(MBT_CONFIG_TYPE_SPEC, 16);
|
memory_book Result = InitBook(sizeof(config_type_spec), 16);
|
||||||
|
|
||||||
config_type_spec *Root = PushTypeSpec(&Result, IDENT_NULL, FALSE);
|
config_type_spec *Root = PushTypeSpec(&Result, IDENT_NULL, FALSE);
|
||||||
PushTypeSpecField(Root, FT_STRING, IDENT_ASSETS_ROOT_DIR, TRUE);
|
PushTypeSpecField(Root, FT_STRING, IDENT_ASSETS_ROOT_DIR, TRUE);
|
||||||
|
@ -1261,7 +1261,7 @@ SetTypeSpec(scope_tree *Type, memory_book *TypeSpecs)
|
||||||
//PrintTypeSpec(Spec);
|
//PrintTypeSpec(Spec);
|
||||||
Type->TypeSpec.ID = Spec->ID;
|
Type->TypeSpec.ID = Spec->ID;
|
||||||
Type->TypeSpec.Permeable = Spec->Permeable;
|
Type->TypeSpec.Permeable = Spec->Permeable;
|
||||||
Type->TypeSpec.Field = InitBook(MBT_CONFIG_TYPE_FIELD, 4);
|
Type->TypeSpec.Field = InitBook(sizeof(config_type_field), 4);
|
||||||
for(int i = 0; i < Spec->Field.ItemCount; ++i)
|
for(int i = 0; i < Spec->Field.ItemCount; ++i)
|
||||||
{
|
{
|
||||||
config_type_field *Src = GetPlaceInBook(&Spec->Field, i);
|
config_type_field *Src = GetPlaceInBook(&Spec->Field, i);
|
||||||
|
@ -1660,10 +1660,10 @@ PushBoolPair(scope_tree *Parent, config_bool_pair *B)
|
||||||
void
|
void
|
||||||
InitScopeBooks(scope_tree *Scope)
|
InitScopeBooks(scope_tree *Scope)
|
||||||
{
|
{
|
||||||
Scope->Trees = InitBook(MBT_SCOPE_TREE, 4);
|
Scope->Trees = InitBook(sizeof(scope_tree), 4);
|
||||||
Scope->Pairs = InitBook(MBT_CONFIG_PAIR, 4);
|
Scope->Pairs = InitBook(sizeof(config_pair), 4);
|
||||||
Scope->IntPairs = InitBook(MBT_CONFIG_INT_PAIR, 4);
|
Scope->IntPairs = InitBook(sizeof(config_int_pair), 4);
|
||||||
Scope->BoolPairs = InitBook(MBT_CONFIG_BOOL_PAIR, 4);
|
Scope->BoolPairs = InitBook(sizeof(config_bool_pair), 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
scope_tree *
|
scope_tree *
|
||||||
|
@ -2411,7 +2411,7 @@ ScopeTokens(scope_tree *Tree, memory_book *TokensList, tokens *T, memory_book *T
|
||||||
{
|
{
|
||||||
int IncludePathTokenIndex = T->CurrentIndex - 1;
|
int IncludePathTokenIndex = T->CurrentIndex - 1;
|
||||||
config_include_rules Rules = {};
|
config_include_rules Rules = {};
|
||||||
Rules.ID = InitBook(MBT_CONFIG_IDENTIFIER_ID, 4);
|
Rules.ID = InitBook(sizeof(config_identifier_id), 4);
|
||||||
switch(ParseIncludeRules(TypeSpecs, &Parent->TypeSpec, T, &Rules))
|
switch(ParseIncludeRules(TypeSpecs, &Parent->TypeSpec, T, &Rules))
|
||||||
{
|
{
|
||||||
case RC_SUCCESS:
|
case RC_SUCCESS:
|
||||||
|
@ -2757,7 +2757,7 @@ string
|
||||||
DeriveLineageOfProject(config *C, scope_tree *Project)
|
DeriveLineageOfProject(config *C, scope_tree *Project)
|
||||||
{
|
{
|
||||||
string Result = {};
|
string Result = {};
|
||||||
memory_book StringList = InitBookOfPointers(MBT_STRING_PTR, 4);
|
memory_book StringList = InitBookOfPointers(4);
|
||||||
if(Project)
|
if(Project)
|
||||||
{
|
{
|
||||||
string **Writer = MakeSpaceInBook(&StringList);
|
string **Writer = MakeSpaceInBook(&StringList);
|
||||||
|
@ -2797,7 +2797,7 @@ string
|
||||||
DeriveLineageWithoutOriginOfProject(config *C, scope_tree *Project)
|
DeriveLineageWithoutOriginOfProject(config *C, scope_tree *Project)
|
||||||
{
|
{
|
||||||
string Result = {};
|
string Result = {};
|
||||||
memory_book StringList = InitBookOfPointers(MBT_STRING_PTR, 4);
|
memory_book StringList = InitBookOfPointers(4);
|
||||||
if(Project->Parent && Project->Parent->ID.Key == IDENT_PROJECT)
|
if(Project->Parent && Project->Parent->ID.Key == IDENT_PROJECT)
|
||||||
{
|
{
|
||||||
string **Writer = MakeSpaceInBook(&StringList);
|
string **Writer = MakeSpaceInBook(&StringList);
|
||||||
|
@ -3116,7 +3116,7 @@ PushVariantUniquely(resolution_errors *E, memory_book *VariantStrings, string Pa
|
||||||
variant_string *NewVariantString = MakeSpaceInBook(VariantStrings);
|
variant_string *NewVariantString = MakeSpaceInBook(VariantStrings);
|
||||||
NewVariantString->Path = Path;
|
NewVariantString->Path = Path;
|
||||||
|
|
||||||
NewVariantString->Variants = InitBook(MBT_VARIANT, 4);
|
NewVariantString->Variants = InitBook(sizeof(variant), 4);
|
||||||
variant *NewVariants = MakeSpaceInBook(&NewVariantString->Variants);
|
variant *NewVariants = MakeSpaceInBook(&NewVariantString->Variants);
|
||||||
*NewVariants = Variants;
|
*NewVariants = Variants;
|
||||||
}
|
}
|
||||||
|
@ -3325,7 +3325,7 @@ PushPersonOntoConfig(config *C, resolution_errors *E, config_verifiers *V, scope
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
This->Support = InitBook(MBT_SUPPORT, 2);
|
This->Support = InitBook(sizeof(support), 2);
|
||||||
for(int i = 0; i < PersonTree->Trees.ItemCount; ++i)
|
for(int i = 0; i < PersonTree->Trees.ItemCount; ++i)
|
||||||
{
|
{
|
||||||
scope_tree *ThisSupport = GetPlaceInBook(&PersonTree->Trees, i);
|
scope_tree *ThisSupport = GetPlaceInBook(&PersonTree->Trees, i);
|
||||||
|
@ -3429,7 +3429,7 @@ void
|
||||||
PushAssociation(config_string_associations *HMMLDirs, string *S0, string *S1, project *P)
|
PushAssociation(config_string_associations *HMMLDirs, string *S0, string *S1, project *P)
|
||||||
{
|
{
|
||||||
config_string_association *This = MakeSpaceInBook(&HMMLDirs->Associations);
|
config_string_association *This = MakeSpaceInBook(&HMMLDirs->Associations);
|
||||||
This->Projects = InitBookOfPointers(MBT_PROJECT_PTR, 4);
|
This->Projects = InitBookOfPointers(4);
|
||||||
|
|
||||||
if(S0) { This->String0 = *S0; }
|
if(S0) { This->String0 = *S0; }
|
||||||
if(S1) { This->String1 = *S1; }
|
if(S1) { This->String1 = *S1; }
|
||||||
|
@ -3508,14 +3508,14 @@ SetUniqueHMMLDir(config *C, resolution_errors *E, config_string_associations *HM
|
||||||
void
|
void
|
||||||
PushProject(config *C, resolution_errors *E, config_verifiers *V, project *P, scope_tree *ProjectTree)
|
PushProject(config *C, resolution_errors *E, config_verifiers *V, project *P, scope_tree *ProjectTree)
|
||||||
{
|
{
|
||||||
P->Medium = InitBook(MBT_MEDIUM, 8);
|
P->Medium = InitBook(sizeof(medium), 8);
|
||||||
P->Child = InitBook(MBT_PROJECT, 8);
|
P->Child = InitBook(sizeof(project), 8);
|
||||||
#if(HMMLIB_MAJOR_VERSION == 2)
|
#if(HMMLIB_MAJOR_VERSION == 2)
|
||||||
P->Credit = InitBook(MBT_CREDIT, 4);
|
P->Credit = InitBook(sizeof(credit), 4);
|
||||||
#else
|
#else
|
||||||
P->Indexer = InitBookOfPointers(MBT_PERSON_PTR, 4);
|
P->Indexer = InitBookOfPointers(4);
|
||||||
P->CoHost = InitBookOfPointers(MBT_PERSON_PTR, 4);
|
P->CoHost = InitBookOfPointers(4);
|
||||||
P->Guest = InitBookOfPointers(MBT_PERSON_PTR, 4);
|
P->Guest = InitBookOfPointers(4);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
config_string_associations *HMMLDirs = &V->HMMLDirs;
|
config_string_associations *HMMLDirs = &V->HMMLDirs;
|
||||||
|
@ -4810,18 +4810,18 @@ config_verifiers
|
||||||
InitVerifiers(void)
|
InitVerifiers(void)
|
||||||
{
|
{
|
||||||
config_verifiers Result = {};
|
config_verifiers Result = {};
|
||||||
Result.VariantStrings = InitBook(MBT_VARIANT_STRING, 8);
|
Result.VariantStrings = InitBook(sizeof(variant_string), 8);
|
||||||
|
|
||||||
Result.HMMLDirs.ID0 = IDENT_HMML_DIR;
|
Result.HMMLDirs.ID0 = IDENT_HMML_DIR;
|
||||||
Result.HMMLDirs.Associations = InitBook(MBT_CONFIG_STRING_ASSOCIATION, 8);
|
Result.HMMLDirs.Associations = InitBook(sizeof(config_string_association), 8);
|
||||||
|
|
||||||
Result.BaseDirAndSearchLocation.ID0 = IDENT_BASE_DIR;
|
Result.BaseDirAndSearchLocation.ID0 = IDENT_BASE_DIR;
|
||||||
Result.BaseDirAndSearchLocation.ID1 = IDENT_SEARCH_LOCATION;
|
Result.BaseDirAndSearchLocation.ID1 = IDENT_SEARCH_LOCATION;
|
||||||
Result.BaseDirAndSearchLocation.Associations = InitBook(MBT_CONFIG_STRING_ASSOCIATION, 8);
|
Result.BaseDirAndSearchLocation.Associations = InitBook(sizeof(config_string_association), 8);
|
||||||
|
|
||||||
Result.BaseDirAndPlayerLocation.ID0 = IDENT_BASE_DIR;
|
Result.BaseDirAndPlayerLocation.ID0 = IDENT_BASE_DIR;
|
||||||
Result.BaseDirAndPlayerLocation.ID1 = IDENT_PLAYER_LOCATION;
|
Result.BaseDirAndPlayerLocation.ID1 = IDENT_PLAYER_LOCATION;
|
||||||
Result.BaseDirAndPlayerLocation.Associations = InitBook(MBT_CONFIG_STRING_ASSOCIATION, 8);
|
Result.BaseDirAndPlayerLocation.Associations = InitBook(sizeof(config_string_association), 8);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4834,7 +4834,7 @@ IsPositioned(config_int_pair *Position)
|
||||||
void
|
void
|
||||||
PositionRolesInConfig(config *C, resolution_errors *E, config_verifiers *V, scope_tree *S)
|
PositionRolesInConfig(config *C, resolution_errors *E, config_verifiers *V, scope_tree *S)
|
||||||
{
|
{
|
||||||
memory_book RolesStaging = InitBookOfPointers(MBT_SCOPE_TREE_PTR, 4);
|
memory_book RolesStaging = InitBookOfPointers(4);
|
||||||
for(int i = 0; i < S->Trees.ItemCount; ++i)
|
for(int i = 0; i < S->Trees.ItemCount; ++i)
|
||||||
{
|
{
|
||||||
scope_tree *Tree = GetPlaceInBook(&S->Trees, i);
|
scope_tree *Tree = GetPlaceInBook(&S->Trees, i);
|
||||||
|
@ -4918,13 +4918,13 @@ ResolveVariables(scope_tree *S)
|
||||||
Assert(LOG_COUNT == ArrayCount(LogLevelStrings));
|
Assert(LOG_COUNT == ArrayCount(LogLevelStrings));
|
||||||
config *Result = calloc(1, sizeof(config));
|
config *Result = calloc(1, sizeof(config));
|
||||||
Result->ResolvedVariables = InitBookOfStrings(Kilobytes(1));
|
Result->ResolvedVariables = InitBookOfStrings(Kilobytes(1));
|
||||||
Result->Person = InitBook(MBT_PERSON, 8);
|
Result->Person = InitBook(sizeof(person), 8);
|
||||||
Result->Role = InitBook(MBT_ROLE, 4);
|
Result->Role = InitBook(sizeof(role), 4);
|
||||||
Result->Project = InitBook(MBT_PROJECT, 8);
|
Result->Project = InitBook(sizeof(project), 8);
|
||||||
|
|
||||||
resolution_errors Errors = {};
|
resolution_errors Errors = {};
|
||||||
Errors.Warnings = InitBook(MBT_RESOLUTION_ERROR, 16);
|
Errors.Warnings = InitBook(sizeof(resolution_error), 16);
|
||||||
Errors.Errors = InitBook(MBT_RESOLUTION_ERROR, 16);
|
Errors.Errors = InitBook(sizeof(resolution_error), 16);
|
||||||
|
|
||||||
config_verifiers Verifiers = InitVerifiers();
|
config_verifiers Verifiers = InitVerifiers();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue