mirror of
https://github.com/Ed94/metadesk.git
synced 2026-07-25 00:47:52 +00:00
progress on compiler errors
This commit is contained in:
Vendored
+8
-1
@@ -76,7 +76,14 @@
|
||||
"push_ignores.inline.h": "c",
|
||||
"list": "c",
|
||||
"xhash": "c",
|
||||
"xtree": "c"
|
||||
"xtree": "c",
|
||||
"os_resolve.h": "c",
|
||||
"os_win32_includes.h": "c",
|
||||
"os_linux_includes.h": "c",
|
||||
"metadesk.h": "c",
|
||||
"mdesk.h": "c",
|
||||
"text.h": "c",
|
||||
"forward_list": "c"
|
||||
},
|
||||
"workbench.colorCustomizations": {
|
||||
"activityBar.activeBackground": "#713fb8",
|
||||
|
||||
+6
-3
@@ -1,5 +1,6 @@
|
||||
# TODO(Ed): Need to eventually utilize the original build scripts
|
||||
# For now just using something I'm used to for getting the library working..
|
||||
clear-host
|
||||
|
||||
$misc = join-path $PSScriptRoot 'helpers/misc.ps1'
|
||||
. $misc
|
||||
@@ -102,7 +103,9 @@ if ($code_sanity)
|
||||
write-host "Building code/metadesk.c (sanity compile) with $vendor"
|
||||
|
||||
$compiler_args = @()
|
||||
# $compiler_args +=
|
||||
$compiler_args += $flag_all_c
|
||||
$compiler_args += $flag_updated_cpp_macro
|
||||
$compiler_args += $flag_c11
|
||||
|
||||
$linker_args = @()
|
||||
$linker_args += $flag_link_win_subsystem_console
|
||||
@@ -110,8 +113,8 @@ if ($code_sanity)
|
||||
$path_base = join-path $path_code base
|
||||
|
||||
$includes = @( $path_base )
|
||||
$unit = join-path $path_base 'base.c'
|
||||
$executable = join-path $path_build 'base.lib'
|
||||
$unit = join-path $path_code 'metadesk.c'
|
||||
$executable = join-path $path_build 'metadesk.lib'
|
||||
|
||||
$result = build-simple $path_build $includes $compiler_args $linker_args $unit $executable
|
||||
}
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ arena_alloc_(ArenaParams* params)
|
||||
//- rjf: arena push/pop core functions
|
||||
|
||||
void*
|
||||
arena_push(Arena *arena, U64 size, U64 align)
|
||||
arena_push(Arena *arena, SSIZE size, SSIZE align)
|
||||
{
|
||||
SPTR const header_size = align_pow2(size_of(Arena), MD_DEFAULT_MEMORY_ALIGNMENT);
|
||||
|
||||
|
||||
+2
-2
@@ -74,8 +74,8 @@ arena_allocator(Arena* arena) {
|
||||
|
||||
//- rjf: arena creation/destruction
|
||||
|
||||
MD_API Arena* arena__alloc(ArenaParams* params);
|
||||
#define arena_alloc(...) arena__alloc( &(ArenaParams){ __VA_ARGS__ } )
|
||||
MD_API Arena* arena__alloc(ArenaParams params);
|
||||
#define arena_alloc(...) arena__alloc( (ArenaParams){ __VA_ARGS__ } )
|
||||
|
||||
void arena_release(Arena *arena);
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
#ifdef INTELLISENSE_DIRECTIVES
|
||||
# include "base.h"
|
||||
#endif
|
||||
|
||||
#undef MARKUP_LAYER_COLOR
|
||||
#define MARKUP_LAYER_COLOR 0.20f, 0.60f, 0.80f
|
||||
|
||||
#include "base.h"
|
||||
|
||||
#include "platform.c"
|
||||
|
||||
MD_NS_BEGIN
|
||||
|
||||
#include "debug.c"
|
||||
#include "memory_substrate.c"
|
||||
#include "arena.c"
|
||||
#include "strings.c"
|
||||
#include "text.c"
|
||||
#include "thread_context.c"
|
||||
#include "command_line.c"
|
||||
#include "logger.c"
|
||||
#include "entry_point.c"
|
||||
#include "time.c"
|
||||
|
||||
MD_NS_END
|
||||
@@ -1,35 +0,0 @@
|
||||
#ifdef INTELLISENSE_DIRECTIVES
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include "context_cracking.h"
|
||||
#include "platform.h"
|
||||
#include "linkage.h"
|
||||
#include "macros.h"
|
||||
#include "generic_macros.h"
|
||||
#include "profiling.h"
|
||||
#include "namespace.h"
|
||||
|
||||
MD_NS_BEGIN
|
||||
|
||||
#include "base_types.h"
|
||||
#include "ring.h"
|
||||
#include "debug.h"
|
||||
#include "memory.h"
|
||||
#include "memory_substrate.h"
|
||||
#include "arena.h"
|
||||
#include "space.h"
|
||||
#include "math.h"
|
||||
#include "sort.h"
|
||||
#include "toolchain.h"
|
||||
#include "strings.h"
|
||||
#include "text.h"
|
||||
#include "thread_context.h"
|
||||
#include "command_line.h"
|
||||
#include "markup.h"
|
||||
#include "logger.h"
|
||||
#include "entry_point.h"
|
||||
#include "time.h"
|
||||
#include "file.h"
|
||||
|
||||
MD_NS_END
|
||||
+12
-2
@@ -9,9 +9,9 @@
|
||||
////////////////////////////////
|
||||
//~ rjf: Globals/Thread-Locals
|
||||
|
||||
MD_API_C thread_static Log *log_active;
|
||||
MD_API_C thread_static Log* log_active;
|
||||
#if !BUILD_SUPPLEMENTARY_UNIT
|
||||
MD_API_C thread_static Log *log_active = 0;
|
||||
MD_API_C thread_static Log* log_active = 0;
|
||||
#endif
|
||||
|
||||
////////////////////////////////
|
||||
@@ -54,6 +54,16 @@ log_msgf(LogMsgKind kind, char *fmt, ...) {
|
||||
////////////////////////////////
|
||||
//~ rjf: Log Scopes
|
||||
|
||||
void
|
||||
log_scope_begin(void) {
|
||||
if (log_active != 0) {
|
||||
U64 pos = arena_pos(log_active->arena);
|
||||
LogScope* scope = push_array(log_active->arena, LogScope, 1);
|
||||
scope->pos = pos;
|
||||
sll_stack_push(log_active->top_scope, scope);
|
||||
}
|
||||
}
|
||||
|
||||
LogScopeResult
|
||||
log_scope_end(Arena *arena)
|
||||
{
|
||||
|
||||
+2
-12
@@ -48,7 +48,7 @@ struct Log
|
||||
////////////////////////////////
|
||||
//~ rjf: Log Creation/Selection
|
||||
|
||||
Log* log_alloc(AllocatorInfo ainfo);
|
||||
Log* log_alloc(AllocatorInfo ainfo, U64 arena_block_size);
|
||||
void log_release(Log* log);
|
||||
MD_API void log_select (Log* log);
|
||||
|
||||
@@ -82,15 +82,5 @@ MD_API void log_msgf(LogMsgKind kind, char* fmt, ...);
|
||||
////////////////////////////////
|
||||
//~ rjf: Log Scopes
|
||||
|
||||
void log_scope_begin(void);
|
||||
MD_API void log_scope_begin(void);
|
||||
MD_API LogScopeResult log_scope_end(Arena* arena);
|
||||
|
||||
inline void
|
||||
log_scope_begin(void) {
|
||||
if (log_active != 0) {
|
||||
U64 pos = arena_pos(log_active->arena);
|
||||
LogScope* scope = push_array(log_active->arena, LogScope, 1);
|
||||
scope->pos = pos;
|
||||
sll_stack_push(log_active->top_scope, scope);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,3 +144,38 @@
|
||||
#ifndef each_non_zero_enum_val
|
||||
#define each_non_zero_enum_val(type, it) type it = (type) 1; it < type ## _COUNT; it = (type)( it + 1 )
|
||||
#endif
|
||||
|
||||
#ifndef stringify
|
||||
#define stringify_(S) #S
|
||||
#define stringify(S) stringify_(S)
|
||||
#endif
|
||||
|
||||
#ifndef glue
|
||||
#define glue_(A,B) A ## B
|
||||
#define glue(A,B) glue_(A,B)
|
||||
#endif
|
||||
|
||||
#define src_line_str stringify(__LINE__)
|
||||
|
||||
#ifndef do_once
|
||||
#define do_once() \
|
||||
local_persist int __do_once_counter_##src_line_str = 0; \
|
||||
for(; __do_once_counter_##src_line_str != 1; __do_once_counter_##src_line_str = 1 ) \
|
||||
|
||||
#define do_once_defer( expression ) \
|
||||
local_persist int __do_once_counter_##src_line_str = 0; \
|
||||
for(;__do_once_counter_##src_line_str != 1; __do_once_counter_##src_line_str = 1, (expression)) \
|
||||
|
||||
#define do_once_start \
|
||||
do \
|
||||
{ \
|
||||
local_persist \
|
||||
bool done = false; \
|
||||
if ( done ) \
|
||||
break; \
|
||||
done = true;
|
||||
|
||||
#define do_once_end \
|
||||
} \
|
||||
while(0);
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifdef INTELLISENSE_DIRECTIVES
|
||||
# pragma once
|
||||
# include "markup.h"
|
||||
#endif
|
||||
|
||||
inline void
|
||||
set_thread_name(String8 string) {
|
||||
prof_thread_name("%.*s", str8_varg(string));
|
||||
os_set_thread_name(string);
|
||||
}
|
||||
+1
-5
@@ -7,11 +7,7 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
inline void
|
||||
set_thread_name(String8 string) {
|
||||
prof_thread_name("%.*s", str8_varg(string));
|
||||
os_set_thread_name(string);
|
||||
}
|
||||
MD_API void set_thread_name(String8 string);
|
||||
|
||||
inline void
|
||||
set_thread_namef(char *fmt, ...)
|
||||
|
||||
@@ -737,16 +737,6 @@ sll__queue_pop_nz(void* nil, void** f, void* f_next, void** l)
|
||||
////////////////////////////////
|
||||
//~ rjf: Misc. Helper Macros
|
||||
|
||||
#ifndef stringify
|
||||
#define stringify_(S) #S
|
||||
#define stringify(S) stringify_(S)
|
||||
#endif
|
||||
|
||||
#ifndef glue
|
||||
#define glue_(A,B) A ## B
|
||||
#define glue(A,B) glue_(A,B)
|
||||
#endif
|
||||
|
||||
#ifndef array_count
|
||||
#define array_count(a) (sizeof(a) / sizeof((a)[0]))
|
||||
#endif
|
||||
|
||||
@@ -189,7 +189,7 @@ heap_allocator_proc( void* allocator_data, AllocatorMode mode, SSIZE size, SSIZE
|
||||
return ptr;
|
||||
}
|
||||
|
||||
VArena
|
||||
VArena*
|
||||
varena__alloc(VArenaParams params)
|
||||
{
|
||||
if (params.reserve_size == 0) {
|
||||
@@ -294,7 +294,7 @@ varena_allocator_proc(void* allocator_data, AllocatorMode mode, SSIZE requested_
|
||||
}
|
||||
|
||||
allocated_mem = rcast(void*, current_offset + size_to_allocate);
|
||||
vm->commit_used += size_to_allocate
|
||||
vm->commit_used += size_to_allocate;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -354,7 +354,7 @@ varena_allocator_proc(void* allocator_data, AllocatorMode mode, SSIZE requested_
|
||||
}
|
||||
|
||||
allocated_mem = old_memory;
|
||||
vm->commit_used += size_to_allocate
|
||||
vm->commit_used += size_to_allocate;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -390,7 +390,7 @@ farena_allocator_proc(void* allocator_data, AllocatorMode mode, SSIZE size, SSIZ
|
||||
{
|
||||
case AllocatorMode_Alloc:
|
||||
{
|
||||
UPTR end = arena->slice.data + arena->used;
|
||||
SPTR end = scast(SPTR, arena->slice.data) + arena->used;
|
||||
SSIZE total_size = align_pow2(size, alignment);
|
||||
|
||||
if (arena->used + total_size > arena->slice.len ) {
|
||||
@@ -398,7 +398,7 @@ farena_allocator_proc(void* allocator_data, AllocatorMode mode, SSIZE size, SSIZ
|
||||
return allocated_mem;
|
||||
}
|
||||
|
||||
allocated_mem = end;
|
||||
allocated_mem = scast(void*, end);
|
||||
arena->used += total_size;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -189,8 +189,8 @@ struct VArena
|
||||
MD_API VArena* varena__alloc(VArenaParams params PARAM_DEFAULT);
|
||||
#define varena_alloc(...) varena__alloc( (VArenaParams){__VA_ARGS__} )
|
||||
|
||||
MD_API void varena_commit (VArena vm, SSIZE commit_size);
|
||||
MD_API VArenaParams varena_release (VArena vm);
|
||||
MD_API void varena_commit (VArena* vm, SSIZE commit_size);
|
||||
MD_API void varena_release(VArena* vm);
|
||||
|
||||
MD_API void* varena_allocator_proc(void* allocator_data, AllocatorMode mode, SSIZE size, SSIZE alignment, void* old_memory, SSIZE old_size, U64 flags);
|
||||
|
||||
|
||||
+31
-31
@@ -612,6 +612,32 @@ str8_list_concat_in_place(String8List* list, String8List* to_push) {
|
||||
}
|
||||
}
|
||||
|
||||
String8Node*
|
||||
str8_list_alloc_aligner(AllocatorInfo ainfo, String8List* list, U64 min, U64 align) {
|
||||
String8Node* node = alloc_array_no_zero(ainfo, String8Node, 1);
|
||||
U64 new_size = list->total_size + min;
|
||||
U64 increase_size = 0;
|
||||
|
||||
if (align > 1) {
|
||||
// NOTE(allen): assert is power of 2
|
||||
assert(((align - 1) & align) == 0);
|
||||
U64 mask = align - 1;
|
||||
new_size += mask;
|
||||
new_size &= (~mask);
|
||||
increase_size = new_size - list->total_size;
|
||||
}
|
||||
|
||||
local_persist const U8 zeroes_buffer[64] = {0};
|
||||
assert(increase_size <= array_count(zeroes_buffer));
|
||||
|
||||
sll_queue_push(list->first, list->last, node);
|
||||
list->node_count += 1;
|
||||
list->total_size = new_size;
|
||||
node->string.str = (U8*)zeroes_buffer;
|
||||
node->string.size = increase_size;
|
||||
return(node);
|
||||
}
|
||||
|
||||
String8Node*
|
||||
str8_list_push_aligner(Arena* arena, String8List* list, U64 min, U64 align)
|
||||
{
|
||||
@@ -639,36 +665,10 @@ str8_list_push_aligner(Arena* arena, String8List* list, U64 min, U64 align)
|
||||
node->string.size = increase_size;
|
||||
return(node);
|
||||
#else
|
||||
return str8_list_aligner(arena_allocator(arena), list, min, align);
|
||||
return str8_list_alloc_aligner(arena_allocator(arena), list, min, align);
|
||||
#endif
|
||||
}
|
||||
|
||||
String8Node*
|
||||
str8_list_aligner(AllocatorInfo ainfo, String8List* list, U64 min, U64 align) {
|
||||
String8Node* node = alloc_array_no_zero(ainfo, String8Node, 1);
|
||||
U64 new_size = list->total_size + min;
|
||||
U64 increase_size = 0;
|
||||
|
||||
if (align > 1) {
|
||||
// NOTE(allen): assert is power of 2
|
||||
assert(((align - 1) & align) == 0);
|
||||
U64 mask = align - 1;
|
||||
new_size += mask;
|
||||
new_size &= (~mask);
|
||||
increase_size = new_size - list->total_size;
|
||||
}
|
||||
|
||||
local_persist const U8 zeroes_buffer[64] = {0};
|
||||
assert(increase_size <= array_count(zeroes_buffer));
|
||||
|
||||
sll_queue_push(list->first, list->last, node);
|
||||
list->node_count += 1;
|
||||
list->total_size = new_size;
|
||||
node->string.str = (U8*)zeroes_buffer;
|
||||
node->string.size = increase_size;
|
||||
return(node);
|
||||
}
|
||||
|
||||
String8List
|
||||
str8_list_copy(Arena *arena, String8List *list) {
|
||||
#if MD_DONT_MAP_ANREA_TO_ALLOCATOR_IMPL
|
||||
@@ -1246,7 +1246,7 @@ str32_from_8(Arena *arena, String8 in){
|
||||
}
|
||||
|
||||
String8
|
||||
str8_from_16(AllocatorInfo ainfo, String16 in) {
|
||||
str8_from_16_alloc(AllocatorInfo ainfo, String16 in) {
|
||||
U64 cap = in.size * 3;
|
||||
U8* str = alloc_array_no_zero(ainfo, U8, cap + 1);
|
||||
U16* ptr = in.str;
|
||||
@@ -1263,7 +1263,7 @@ str8_from_16(AllocatorInfo ainfo, String16 in) {
|
||||
}
|
||||
|
||||
String16
|
||||
str16_from_8(AllocatorInfo ainfo, String8 in) {
|
||||
str16_from_8_alloc(AllocatorInfo ainfo, String8 in) {
|
||||
U64 cap = in.size * 2;
|
||||
U16* str = alloc_array_no_zero(ainfo, U16, cap + 1);
|
||||
U8* ptr = in.str;
|
||||
@@ -1280,7 +1280,7 @@ str16_from_8(AllocatorInfo ainfo, String8 in) {
|
||||
}
|
||||
|
||||
String8
|
||||
str8_from_32(AllocatorInfo ainfo, String32 in){
|
||||
str8_from_32_alloc(AllocatorInfo ainfo, String32 in){
|
||||
U64 cap = in.size * 4;
|
||||
U8* str = alloc_array_no_zero(ainfo, U8, cap + 1);
|
||||
U32* ptr = in.str;
|
||||
@@ -1295,7 +1295,7 @@ str8_from_32(AllocatorInfo ainfo, String32 in){
|
||||
}
|
||||
|
||||
String32
|
||||
str32_from_8(AllocatorInfo ainfo, String8 in){
|
||||
str32_from_8_alloc(AllocatorInfo ainfo, String8 in){
|
||||
U64 cap = in.size;
|
||||
U32* str = alloc_array_no_zero(ainfo, U32, cap + 1);
|
||||
U8* ptr = in.str;
|
||||
|
||||
+137
-130
@@ -154,7 +154,7 @@ struct FuzzyMatchRangeList
|
||||
|
||||
inline U8
|
||||
integer_symbols(U8 value) {
|
||||
read_only local_persist thread_local
|
||||
read_only local_persist
|
||||
U8 lookup_table[16] = {
|
||||
'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',
|
||||
};
|
||||
@@ -163,7 +163,7 @@ integer_symbols(U8 value) {
|
||||
|
||||
inline U8
|
||||
base64(U8 value) {
|
||||
read_only local_persist thread_local
|
||||
read_only local_persist
|
||||
U8 lookup_table[64] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
||||
@@ -177,7 +177,7 @@ base64(U8 value) {
|
||||
|
||||
inline U8
|
||||
base64_reverse(U8 value) {
|
||||
read_only local_persist thread_local
|
||||
read_only local_persist
|
||||
U8 lookup_table[128] = {
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
@@ -194,7 +194,7 @@ base64_reverse(U8 value) {
|
||||
// NOTE(allen): Includes reverses for uppercase and lowercase hex.
|
||||
inline U8
|
||||
integer_symbol_reverse(U8 value) {
|
||||
read_only local_persist thread_local
|
||||
read_only local_persist
|
||||
lookup_table[128] = {
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
@@ -311,33 +311,34 @@ str8_cstring_capped_reverse(void* raw_start, void* raw_cap)
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: String Stylization
|
||||
//~ rjf: String Formatting & Copying
|
||||
|
||||
inline String8 upper_from_str8 (Arena* arena, String8 string) { string = push_str8_copy(arena, string); for(U64 idx = 0; idx < string.size; idx += 1) { string.str[idx] = char_to_upper(string.str[idx]); } return string; }
|
||||
inline String8 lower_from_str8 (Arena* arena, String8 string) { string = push_str8_copy(arena, string); for(U64 idx = 0; idx < string.size; idx += 1) { string.str[idx] = char_to_lower(string.str[idx]); } return string; }
|
||||
inline String8 backslashed_from_str8(Arena *arena, String8 string) { string = push_str8_copy(arena, string); for(U64 idx = 0; idx < string.size; idx += 1) { string.str[idx] = char_is_slash(string.str[idx]) ? '\\' : string.str[idx]; } return string; }
|
||||
MD_API String8 push_str8_cat (Arena* arena, String8 s1, String8 s2);
|
||||
MD_API String8 push_str8_copy(Arena* arena, String8 s);
|
||||
MD_API String8 push_str8fv (Arena* arena, char* fmt, va_list args);
|
||||
String8 push_str8f (Arena* arena, char* fmt, ...);
|
||||
|
||||
inline String8 upper_from_str8_alloc (AllocatorInfo ainfo, String8 string) { string = alloc_str8_copy(ainfo, string); for(U64 idx = 0; idx < string.size; idx += 1) { string.str[idx] = char_to_upper(string.str[idx]); } return string; }
|
||||
inline String8 lower_from_str8_alloc (AllocatorInfo ainfo, String8 string) { string = alloc_str8_copy(ainfo, string); for(U64 idx = 0; idx < string.size; idx += 1) { string.str[idx] = char_to_lower(string.str[idx]); } return string; }
|
||||
inline String8 backslashed_from_str8_alloc(AllocatorInfo ainfo, String8 string) { string = alloc_str8_copy(ainfo, string); for(U64 idx = 0; idx < string.size; idx += 1) { string.str[idx] = char_is_slash(string.str[idx]) ? '\\' : string.str[idx]; } return string; }
|
||||
MD_API String8 alloc_str8_cat (AllocatorInfo ainfo, String8 s1, String8 s2);
|
||||
MD_API String8 alloc_str8_copy(AllocatorInfo ainfo, String8 s);
|
||||
MD_API String8 alloc_str8fv (AllocatorInfo ainfo, char* fmt, va_list args);
|
||||
String8 alloc_str8f (AllocatorInfo ainfo, char* fmt, ...);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: String Matching
|
||||
inline String8
|
||||
push_str8f(Arena *arena, char *fmt, ...){
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
String8 result = push_str8fv(arena, fmt, args);
|
||||
va_end(args);
|
||||
return(result);
|
||||
}
|
||||
|
||||
#define str8_match_lit(a_lit, b, flags) str8_match(str8_lit(a_lit), (b), (flags))
|
||||
#define str8_match_cstr(a_cstr, b, flags) str8_match(str8_cstring(a_cstr), (b), (flags))
|
||||
#define str8_ends_with_lit(string, end_lit, flags) str8_ends_with((string), str8_lit(end_lit), (flags))
|
||||
|
||||
MD_API B32 str8_match (String8 a, String8 b, StringMatchFlags flags);
|
||||
MD_API U64 str8_find_needle (String8 string, U64 start_pos, String8 needle, StringMatchFlags flags);
|
||||
MD_API U64 str8_find_needle_reverse(String8 string, U64 start_pos, String8 needle, StringMatchFlags flags);
|
||||
B32 str8_ends_with (String8 string, String8 end, StringMatchFlags flags);
|
||||
|
||||
inline B32
|
||||
str8_ends_with(String8 string, String8 end, StringMatchFlags flags) {
|
||||
String8 postfix = str8_postfix(string, end.size);
|
||||
B32 is_match = str8_match(end, postfix, flags);
|
||||
return is_match;
|
||||
inline String8
|
||||
alloc_str8f(AllocatorInfo ainfo, char *fmt, ...){
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
String8 result = alloc_str8fv(ainfo, fmt, args);
|
||||
va_end(args);
|
||||
return(result);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
@@ -390,34 +391,33 @@ str8_chop(String8 str, U64 amt){
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: String Formatting & Copying
|
||||
//~ rjf: String Stylization
|
||||
|
||||
MD_API String8 push_str8_cat (Arena* arena, String8 s1, String8 s2);
|
||||
MD_API String8 push_str8_copy(Arena* arena, String8 s);
|
||||
MD_API String8 push_str8fv (Arena* arena, char* fmt, va_list args);
|
||||
String8 push_str8f (Arena* arena, char* fmt, ...);
|
||||
inline String8 upper_from_str8 (Arena* arena, String8 string) { string = push_str8_copy(arena, string); for(U64 idx = 0; idx < string.size; idx += 1) { string.str[idx] = char_to_upper(string.str[idx]); } return string; }
|
||||
inline String8 lower_from_str8 (Arena* arena, String8 string) { string = push_str8_copy(arena, string); for(U64 idx = 0; idx < string.size; idx += 1) { string.str[idx] = char_to_lower(string.str[idx]); } return string; }
|
||||
inline String8 backslashed_from_str8(Arena *arena, String8 string) { string = push_str8_copy(arena, string); for(U64 idx = 0; idx < string.size; idx += 1) { string.str[idx] = char_is_slash(string.str[idx]) ? '\\' : string.str[idx]; } return string; }
|
||||
|
||||
MD_API String8 alloc_str8_cat (AllocatorInfo ainfo, String8 s1, String8 s2);
|
||||
MD_API String8 alloc_str8_copy(AllocatorInfo ainfo, String8 s);
|
||||
MD_API String8 alloc_str8fv (AllocatorInfo ainfo, char* fmt, va_list args);
|
||||
String8 alloc_str8f (AllocatorInfo ainfo, char* fmt, ...);
|
||||
inline String8 upper_from_str8_alloc (AllocatorInfo ainfo, String8 string) { string = alloc_str8_copy(ainfo, string); for(U64 idx = 0; idx < string.size; idx += 1) { string.str[idx] = char_to_upper(string.str[idx]); } return string; }
|
||||
inline String8 lower_from_str8_alloc (AllocatorInfo ainfo, String8 string) { string = alloc_str8_copy(ainfo, string); for(U64 idx = 0; idx < string.size; idx += 1) { string.str[idx] = char_to_lower(string.str[idx]); } return string; }
|
||||
inline String8 backslashed_from_str8_alloc(AllocatorInfo ainfo, String8 string) { string = alloc_str8_copy(ainfo, string); for(U64 idx = 0; idx < string.size; idx += 1) { string.str[idx] = char_is_slash(string.str[idx]) ? '\\' : string.str[idx]; } return string; }
|
||||
|
||||
inline String8
|
||||
push_str8f(Arena *arena, char *fmt, ...){
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
String8 result = push_str8fv(arena, fmt, args);
|
||||
va_end(args);
|
||||
return(result);
|
||||
}
|
||||
////////////////////////////////
|
||||
//~ rjf: String Matching
|
||||
|
||||
inline String8
|
||||
alloc_str8f(AllocatorInfo ainfo, char *fmt, ...){
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
String8 result = alloc_str8fv(ainfo, fmt, args);
|
||||
va_end(args);
|
||||
return(result);
|
||||
#define str8_match_lit(a_lit, b, flags) str8_match(str8_lit(a_lit), (b), (flags))
|
||||
#define str8_match_cstr(a_cstr, b, flags) str8_match(str8_cstring(a_cstr), (b), (flags))
|
||||
#define str8_ends_with_lit(string, end_lit, flags) str8_ends_with((string), str8_lit(end_lit), (flags))
|
||||
|
||||
MD_API B32 str8_match (String8 a, String8 b, StringMatchFlags flags);
|
||||
MD_API U64 str8_find_needle (String8 string, U64 start_pos, String8 needle, StringMatchFlags flags);
|
||||
MD_API U64 str8_find_needle_reverse(String8 string, U64 start_pos, String8 needle, StringMatchFlags flags);
|
||||
B32 str8_ends_with (String8 string, String8 end, StringMatchFlags flags);
|
||||
|
||||
inline B32
|
||||
str8_ends_with(String8 string, String8 end, StringMatchFlags flags) {
|
||||
String8 postfix = str8_postfix(string, end.size);
|
||||
B32 is_match = str8_match(end, postfix, flags);
|
||||
return is_match;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
@@ -699,7 +699,7 @@ str8_split_by_string_chars(Arena *arena, String8 string, String8 split_chars, St
|
||||
}
|
||||
|
||||
inline String8List
|
||||
str8_split_by_string_chars(AllocatorInfo ainfo, String8 string, String8 split_chars, StringSplitFlags flags) {
|
||||
str8_split_by_string_chars_alloc(AllocatorInfo ainfo, String8 string, String8 split_chars, StringSplitFlags flags) {
|
||||
String8List list = str8_split_alloc(ainfo, string, split_chars.str, split_chars.size, flags);
|
||||
return list;
|
||||
}
|
||||
@@ -738,7 +738,7 @@ str8_list_from_flags(Arena* arena, String8List* list, U32 flags, String8* flag_s
|
||||
}
|
||||
}
|
||||
#else
|
||||
return str8_list_from_flags_alloc(arena_allocator(arena), list, flags, flag_string_table, flag_string_count);
|
||||
str8_list_from_flags_alloc(arena_allocator(arena), list, flags, flag_string_table, flag_string_count);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -755,6 +755,25 @@ str8_list_from_flags_alloc(AllocatorInfo ainfo, String8List* list, U32 flags, St
|
||||
////////////////////////////////
|
||||
//~ rjf; String Arrays
|
||||
|
||||
inline String8Array
|
||||
str8_array_from_list_alloc(AllocatorInfo ainfo, String8List* list) {
|
||||
String8Array array;
|
||||
array.count = list->node_count;
|
||||
array.v = alloc_array_no_zero(ainfo, String8, array.count);
|
||||
U64 idx = 0;
|
||||
for(String8Node *n = list->first; n != 0; n = n->next, idx += 1) {
|
||||
array.v[idx] = n->string;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
inline String8Array
|
||||
str8_array_reserve_alloc(AllocatorInfo ainfo, U64 count) {
|
||||
String8Array arr;
|
||||
arr.count = 0;
|
||||
arr.v = alloc_array(ainfo, String8, count);
|
||||
return arr;
|
||||
}
|
||||
|
||||
inline String8Array
|
||||
str8_array_from_list(Arena* arena, String8List* list) {
|
||||
@@ -784,26 +803,6 @@ str8_array_reserve(Arena *arena, U64 count) {
|
||||
#endif
|
||||
}
|
||||
|
||||
inline String8Array
|
||||
str8_array_from_list_alloc(AllocatorInfo ainfo, String8List* list) {
|
||||
String8Array array;
|
||||
array.count = list->node_count;
|
||||
array.v = alloc_array_no_zero(ainfo, String8, array.count);
|
||||
U64 idx = 0;
|
||||
for(String8Node *n = list->first; n != 0; n = n->next, idx += 1) {
|
||||
array.v[idx] = n->string;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
inline String8Array
|
||||
str8_array_reserve_alloc(AllocatorInfo ainfo, U64 count) {
|
||||
String8Array arr;
|
||||
arr.count = 0;
|
||||
arr.v = alloc_array(ainfo, String8, count);
|
||||
return arr;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: String Path Helpers
|
||||
|
||||
@@ -825,7 +824,7 @@ MD_API String8 str8_path_list_join_by_style_alloc (AllocatorInfo ainfo, Str
|
||||
inline U8
|
||||
utf8_class(U8 value)
|
||||
{
|
||||
read_only local_persist thread_local
|
||||
read_only local_persist
|
||||
U8 lookup_table[32] = {
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,2,2,2,2,3,3,4,5,
|
||||
};
|
||||
@@ -937,7 +936,8 @@ string_from_architecture(Arch arch) {
|
||||
//~ rjf: Time Types -> String
|
||||
|
||||
inline String8
|
||||
string_from_week_day(WeekDay week_day) {
|
||||
string_from_week_day(WeekDay week_day)
|
||||
{
|
||||
local_persist String8 strings[] = {
|
||||
str8_lit_comp("Sun"),
|
||||
str8_lit_comp("Mon"),
|
||||
@@ -955,7 +955,8 @@ string_from_week_day(WeekDay week_day) {
|
||||
}
|
||||
|
||||
inline String8
|
||||
string_from_month(Month month) {
|
||||
string_from_month(Month month)
|
||||
{
|
||||
local_persist String8 strings[] = {
|
||||
str8_lit_comp("Jan"),
|
||||
str8_lit_comp("Feb"),
|
||||
@@ -1064,6 +1065,61 @@ str8_serial_write_to_dst(String8List* srl, void* out) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void str8_serial_begin_alloc (AllocatorInfo ainfo, String8List* srl);
|
||||
String8 str8_serial_end_alloc (AllocatorInfo ainfo, String8List* srl);
|
||||
MD_API U64 str8_serial_alloc_align (AllocatorInfo ainfo, String8List* srl, U64 align);
|
||||
MD_API void* str8_serial_alloc_size (AllocatorInfo ainfo, String8List* srl, U64 size);
|
||||
void* str8_serial_alloc_data (AllocatorInfo ainfo, String8List* srl, void* data, U64 size);
|
||||
void str8_serial_alloc_data_list(AllocatorInfo ainfo, String8List* srl, String8Node* first);
|
||||
MD_API void str8_serial_alloc_u64 (AllocatorInfo ainfo, String8List* srl, U64 x);
|
||||
MD_API void str8_serial_alloc_u32 (AllocatorInfo ainfo, String8List* srl, U32 x);
|
||||
void str8_serial_alloc_u16 (AllocatorInfo ainfo, String8List* srl, U16 x);
|
||||
void str8_serial_alloc_u8 (AllocatorInfo ainfo, String8List* srl, U8 x);
|
||||
void str8_serial_alloc_cstr (AllocatorInfo ainfo, String8List* srl, String8 str);
|
||||
void str8_serial_alloc_string (AllocatorInfo ainfo, String8List* srl, String8 str);
|
||||
|
||||
inline void
|
||||
str8_serial_begin_alloc(AllocatorInfo ainfo, String8List* srl) {
|
||||
String8Node* node = alloc_array(ainfo, String8Node, 1);
|
||||
node->string.str = alloc_array_no_zero(ainfo, U8, 0);
|
||||
srl->first = srl->last = node;
|
||||
srl->node_count = 1;
|
||||
srl->total_size = 0;
|
||||
}
|
||||
|
||||
inline String8
|
||||
str8_serial_end_alloc(AllocatorInfo ainfo, String8List* srl) {
|
||||
U64 size = srl->total_size;
|
||||
U8* out = alloc_array_no_zero(ainfo, U8, size);
|
||||
str8_serial_write_to_dst(srl, out);
|
||||
String8 result = str8(out, size);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline void*
|
||||
str8_serial_alloc_data(AllocatorInfo ainfo, String8List* srl, void* data, U64 size){
|
||||
void* result = str8_serial_alloc_size(ainfo, srl, size);
|
||||
if(result != 0) {
|
||||
memory_copy(result, data, size);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline void
|
||||
str8_serial_alloc_data_list(AllocatorInfo ainfo, String8List* srl, String8Node* first){
|
||||
for (String8Node* node = first; node != 0; node = node->next) {
|
||||
str8_serial_alloc_data(ainfo, srl, node->string.str, node->string.size);
|
||||
}
|
||||
}
|
||||
|
||||
inline void str8_serial_alloc_u16(AllocatorInfo ainfo, String8List* srl, U16 x) { str8_serial_alloc_data(ainfo, srl, &x, sizeof(x)); }
|
||||
inline void str8_serial_alloc_u8 (AllocatorInfo ainfo, String8List* srl, U8 x) { str8_serial_alloc_data(ainfo, srl, &x, sizeof(x)); }
|
||||
|
||||
inline void str8_serial_alloc_cstr (AllocatorInfo ainfo, String8List* srl, String8 str) { str8_serial_alloc_data(ainfo, srl, str.str, str.size); str8_serial_alloc_u8(ainfo, srl, 0); }
|
||||
inline void str8_serial_alloc_string(AllocatorInfo ainfo, String8List* srl, String8 str) { str8_serial_alloc_data(ainfo, srl, str.str, str.size); }
|
||||
|
||||
|
||||
void str8_serial_begin (Arena* arena, String8List* srl);
|
||||
String8 str8_serial_end (Arena* arena, String8List* srl);
|
||||
MD_API U64 str8_serial_push_align (Arena* arena, String8List* srl, U64 align);
|
||||
@@ -1078,12 +1134,16 @@ MD_API void str8_serial_push_u32 (Arena* arena, String8List* srl, U32 x)
|
||||
void str8_serial_push_string (Arena* arena, String8List* srl, String8 str);
|
||||
|
||||
inline void
|
||||
str8_serial_begin(Arena* arena, String8List* srl){
|
||||
str8_serial_begin(Arena* arena, String8List* srl) {
|
||||
#if MD_DONT_MAP_ARENA_TO_ALLOCATOR_IMPL
|
||||
String8Node* node = push_array(arena, String8Node, 1);
|
||||
node->string.str = push_array_no_zero(arena, U8, 0);
|
||||
srl->first = srl->last = node;
|
||||
srl->node_count = 1;
|
||||
srl->total_size = 0;
|
||||
#else
|
||||
str8_serial_begin_alloc(arena_allocator(arena), srl);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline String8
|
||||
@@ -1117,59 +1177,6 @@ inline void str8_serial_push_u8 (Arena* arena, String8List* srl, U8 x) { str8_s
|
||||
inline void str8_serial_push_cstr (Arena* arena, String8List* srl, String8 str) { str8_serial_push_data(arena, srl, str.str, str.size); str8_serial_push_u8(arena, srl, 0); }
|
||||
inline void str8_serial_push_string(Arena* arena, String8List* srl, String8 str) { str8_serial_push_data(arena, srl, str.str, str.size); }
|
||||
|
||||
void str8_serial_begin_alloc (AllocatorInfo ainfo, String8List* srl);
|
||||
String8 str8_serial_end_alloc (AllocatorInfo ainfo, String8List* srl);
|
||||
MD_API U64 str8_serial_alloc_align (AllocatorInfo ainfo, String8List* srl, U64 align);
|
||||
MD_API void* str8_serial_alloc_size (AllocatorInfo ainfo, String8List* srl, U64 size);
|
||||
void* str8_serial_alloc_data (AllocatorInfo ainfo, String8List* srl, void* data, U64 size);
|
||||
void str8_serial_alloc_data_list(AllocatorInfo ainfo, String8List* srl, String8Node* first);
|
||||
MD_API void str8_serial_alloc_u64 (AllocatorInfo ainfo, String8List* srl, U64 x);
|
||||
MD_API void str8_serial_alloc_u32 (AllocatorInfo ainfo, String8List* srl, U32 x);
|
||||
void str8_serial_alloc_u16 (AllocatorInfo ainfo, String8List* srl, U16 x);
|
||||
void str8_serial_alloc_u8 (AllocatorInfo ainfo, String8List* srl, U8 x);
|
||||
void str8_serial_alloc_cstr (AllocatorInfo ainfo, String8List* srl, String8 str);
|
||||
void str8_serial_alloc_string (AllocatorInfo ainfo, String8List* srl, String8 str);
|
||||
|
||||
inline void
|
||||
str8_serial_begin(AllocatorInfo ainfo, String8List* srl) {
|
||||
String8Node* node = alloc_array(ainfo, String8Node, 1);
|
||||
node->string.str = alloc_array_no_zero(ainfo, U8, 0);
|
||||
srl->first = srl->last = node;
|
||||
srl->node_count = 1;
|
||||
srl->total_size = 0;
|
||||
}
|
||||
|
||||
inline String8
|
||||
str8_serial_end(AllocatorInfo ainfo, String8List* srl) {
|
||||
U64 size = srl->total_size;
|
||||
U8* out = alloc_array_no_zero(ainfo, U8, size);
|
||||
str8_serial_write_to_dst(srl, out);
|
||||
String8 result = str8(out, size);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline void*
|
||||
str8_serial_push_data(AllocatorInfo ainfo, String8List* srl, void* data, U64 size){
|
||||
void* result = str8_serial_alloc_size(ainfo, srl, size);
|
||||
if(result != 0) {
|
||||
memory_copy(result, data, size);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline void
|
||||
str8_serial_push_data_list(AllocatorInfo ainfo, String8List* srl, String8Node* first){
|
||||
for (String8Node* node = first; node != 0; node = node->next) {
|
||||
str8_serial_alloc_data(ainfo, srl, node->string.str, node->string.size);
|
||||
}
|
||||
}
|
||||
|
||||
inline void str8_serial_alloc_u16(AllocatorInfo ainfo, String8List* srl, U16 x) { str8_serial_alloc_data(ainfo, srl, &x, sizeof(x)); }
|
||||
inline void str8_serial_alloc_u8 (AllocatorInfo ainfo, String8List* srl, U8 x) { str8_serial_alloc_data(ainfo, srl, &x, sizeof(x)); }
|
||||
|
||||
inline void str8_serial_push_cstr (AllocatorInfo ainfo, String8List* srl, String8 str) { str8_serial_alloc_data(ainfo, srl, str.str, str.size); str8_serial_alloc_u8(ainfo, srl, 0); }
|
||||
inline void str8_serial_push_string(AllocatorInfo ainfo, String8List* srl, String8 str) { str8_serial_alloc_data(ainfo, srl, str.str, str.size); }
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Deserialization Helpers
|
||||
|
||||
|
||||
+6
-6
@@ -6,7 +6,8 @@
|
||||
////////////////////////////////
|
||||
//~ allen: Time
|
||||
|
||||
typedef enum WeekDay
|
||||
typedef enum WeekDay WeekDay;
|
||||
enum Weekday
|
||||
{
|
||||
WeekDay_Sun,
|
||||
WeekDay_Mon,
|
||||
@@ -16,10 +17,10 @@ typedef enum WeekDay
|
||||
WeekDay_Fri,
|
||||
WeekDay_Sat,
|
||||
WeekDay_COUNT,
|
||||
}
|
||||
WeekDay;
|
||||
};
|
||||
|
||||
typedef enum Month
|
||||
typedef enum Month Month;
|
||||
enum Month
|
||||
{
|
||||
Month_Jan,
|
||||
Month_Feb,
|
||||
@@ -34,8 +35,7 @@ typedef enum Month
|
||||
Month_Nov,
|
||||
Month_Dec,
|
||||
Month_COUNT,
|
||||
}
|
||||
Month;
|
||||
};
|
||||
|
||||
typedef struct DateTime DateTime;
|
||||
struct DateTime
|
||||
|
||||
+3
-3
@@ -687,7 +687,7 @@ parse_from_text_tokens(Arena* arena, String8 filename, String8 text, TokenArray
|
||||
|
||||
// TODO(Ed): Add opt-in support for comment awareness
|
||||
//- rjf: comments -> always no-op & inc
|
||||
if (token->flags & TokenGroup_Comment) {
|
||||
if (token->flags & TokenFlagGroup_Comment) {
|
||||
token += 1;
|
||||
goto end_consume;
|
||||
// < // > <content> <unescaped newline>
|
||||
@@ -763,7 +763,7 @@ parse_from_text_tokens(Arena* arena, String8 filename, String8 text, TokenArray
|
||||
if (mode_main_or_main_implict && found_tag)
|
||||
{
|
||||
// Token after should be label.
|
||||
if (token + 1 >= tokens_opl || !(token[1].flags & TokenGroup_Label))
|
||||
if (token + 1 >= tokens_opl || !(token[1].flags & TokenFlagGroup_Label))
|
||||
{
|
||||
Node* error = push_node(arena, NodeKind_ErrorMarker, 0, token_string, token_string, token->range.min);
|
||||
String8 error_string = str8_lit("Tag label expected after @ symbol.");
|
||||
@@ -797,7 +797,7 @@ parse_from_text_tokens(Arena* arena, String8 filename, String8 text, TokenArray
|
||||
}
|
||||
|
||||
//- rjf: [main, main_implicit] label -> create new main
|
||||
if (mode_main_or_main_implict && token->flags & TokenGroup_Label)
|
||||
if (mode_main_or_main_implict && token->flags & TokenFlagGroup_Label)
|
||||
{
|
||||
String8 node_string_raw = token_string;
|
||||
String8 node_string = content_string_from_token_flags_str8(token->flags, node_string_raw);
|
||||
|
||||
+10
-10
@@ -1,6 +1,5 @@
|
||||
#if INTELLISENSE_DIRECTIVES
|
||||
# pragma once
|
||||
# include "base/base.h"
|
||||
# include "os/os.h"
|
||||
#endif
|
||||
|
||||
@@ -70,15 +69,15 @@ enum
|
||||
TokenFlag_BadCharacter = (1 << 14),
|
||||
};
|
||||
|
||||
typedef U32 TokenGroups;
|
||||
typedef U32 TokenFlagGroups;
|
||||
enum
|
||||
{
|
||||
TokenGroup_Comment = TokenFlag_Comment,
|
||||
TokenGroup_Whitespace = (TokenFlag_Whitespace| TokenFlag_Newline),
|
||||
TokenGroup_Irregular = (TokenGroup_Comment | TokenGroup_Whitespace),
|
||||
TokenGroup_Regular = ~TokenGroup_Irregular,
|
||||
TokenGroup_Label = (TokenFlag_Identifier | TokenFlag_Numeric | TokenFlag_StringLiteral | TokenFlag_Symbol),
|
||||
TokenGroup_Error = (TokenFlag_BrokenComment | TokenFlag_BrokenStringLiteral | TokenFlag_BadCharacter),
|
||||
TokenFlagGroup_Comment = TokenFlag_Comment,
|
||||
TokenFlagGroup_Whitespace = (TokenFlag_Whitespace| TokenFlag_Newline),
|
||||
TokenFlagGroup_Irregular = (TokenFlagGroup_Comment | TokenFlagGroup_Whitespace),
|
||||
TokenFlagGroup_Regular = ~TokenFlagGroup_Irregular,
|
||||
TokenFlagGroup_Label = (TokenFlag_Identifier | TokenFlag_Numeric | TokenFlag_StringLiteral | TokenFlag_Symbol),
|
||||
TokenFlagGroup_Error = (TokenFlag_BrokenComment | TokenFlag_BrokenStringLiteral | TokenFlag_BadCharacter),
|
||||
};
|
||||
|
||||
typedef struct Token Token;
|
||||
@@ -228,8 +227,9 @@ struct ParseResult
|
||||
inline Node*
|
||||
nil_node()
|
||||
{
|
||||
read_only thread_local local_persist
|
||||
nil = {
|
||||
read_only local_persist
|
||||
Node nil =
|
||||
{
|
||||
&nil,
|
||||
&nil,
|
||||
&nil,
|
||||
|
||||
+20
-7
@@ -1,17 +1,30 @@
|
||||
#ifdef INTELLISENSE_DIRECTIVES
|
||||
# include "metadesk.h"
|
||||
#endif
|
||||
#include "metadesk.h"
|
||||
|
||||
#include "base/base.c"
|
||||
#undef MARKUP_LAYER_COLOR
|
||||
#define MARKUP_LAYER_COLOR 0.20f, 0.60f, 0.80f
|
||||
|
||||
#include "base/platform.c"
|
||||
|
||||
MD_NS_BEGIN
|
||||
|
||||
#include "base/debug.c"
|
||||
#include "base/memory_substrate.c"
|
||||
#include "base/arena.c"
|
||||
#include "base/strings.c"
|
||||
#include "base/text.c"
|
||||
#include "base/thread_context.c"
|
||||
#include "base/command_line.c"
|
||||
#include "base/logger.c"
|
||||
#include "base/entry_point.c"
|
||||
#include "base/time.c"
|
||||
|
||||
#if OS_WINDOWS
|
||||
# include "os/win32/os_win32.c"
|
||||
#elif OS_LINUX
|
||||
# include "os/linux/os_linux.c"
|
||||
#else
|
||||
# error OS core layer not implemented for this operating system.
|
||||
# include "os/win32/os_win32.c"
|
||||
#endif
|
||||
|
||||
#include "os/os.c"
|
||||
|
||||
#include "mdesk/mdesk.c"
|
||||
MD_NS_END
|
||||
|
||||
+39
-1
@@ -2,6 +2,44 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include "base/base.h"
|
||||
#include "base/context_cracking.h"
|
||||
#include "base/platform.h"
|
||||
#include "base/linkage.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/generic_macros.h"
|
||||
#include "base/profiling.h"
|
||||
#include "base/namespace.h"
|
||||
|
||||
MD_NS_BEGIN
|
||||
|
||||
#include "base/base_types.h"
|
||||
#include "base/ring.h"
|
||||
#include "base/debug.h"
|
||||
#include "base/memory.h"
|
||||
#include "base/memory_substrate.h"
|
||||
#include "base/arena.h"
|
||||
#include "base/space.h"
|
||||
#include "base/math.h"
|
||||
#include "base/sort.h"
|
||||
#include "base/toolchain.h"
|
||||
#include "base/time.h"
|
||||
#include "base/strings.h"
|
||||
#include "base/text.h"
|
||||
#include "base/thread_context.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/markup.h"
|
||||
#include "base/logger.h"
|
||||
#include "base/entry_point.h"
|
||||
#include "base/file.h"
|
||||
|
||||
#include "os/os.h"
|
||||
|
||||
MD_NS_END
|
||||
|
||||
#include "os/os_resolve.h"
|
||||
|
||||
MD_NS_BEGIN
|
||||
|
||||
#include "mdesk/mdesk.h"
|
||||
|
||||
MD_NS_END
|
||||
|
||||
@@ -1,33 +1,15 @@
|
||||
#ifdef INTELLISENSE_DIRECTIVES
|
||||
# pragma once
|
||||
# include "base/base.h"
|
||||
# include "base/debug.h"
|
||||
# include "base/strings.h"
|
||||
# include "base/thread_context.h"
|
||||
# include "os/os.h"
|
||||
# include "os/linux/os_linux_includes.h"
|
||||
#endif
|
||||
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Includes
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <features.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/limits.h>
|
||||
#include <time.h>
|
||||
#include <dirent.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <dlfcn.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/random.h>
|
||||
|
||||
int pthread_setname_np(pthread_t thread, const char* name);
|
||||
int pthread_getname_np(pthread_t thread, char* name, size_t size);
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifdef INTELLISENSE_DIRECTIVES
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Includes
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <features.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/limits.h>
|
||||
#include <time.h>
|
||||
#include <dirent.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <dlfcn.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/random.h>
|
||||
+49
-63
@@ -1,22 +1,8 @@
|
||||
#ifdef INTELLISENSE_DIRECTIVES
|
||||
# pragma once
|
||||
# include "base/base.h"
|
||||
#endif
|
||||
|
||||
#if !defined(OS_FEATURE_GRAPHICAL)
|
||||
# define OS_FEATURE_GRAPHICAL 0
|
||||
#endif
|
||||
|
||||
#if !defined(OS_GFX_STUB)
|
||||
# define OS_GFX_STUB 0
|
||||
#endif
|
||||
|
||||
#if OS_WINDOWS
|
||||
# include "os/win32/os_win32.h"
|
||||
#elif OS_LINUX
|
||||
# include "os/linux/os_linux.h"
|
||||
#else
|
||||
# error OS core layer not implemented for this operating system.
|
||||
# include "base/file.h"
|
||||
# include "base/debug.h"
|
||||
# include "os_resolve.h"
|
||||
#endif
|
||||
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
@@ -177,7 +163,7 @@ os_handle_list_push(Arena* arena, OS_HandleList* handles, OS_Handle handle) {
|
||||
sll_queue_push(handles->first, handles->last, n);
|
||||
handles->count += 1;
|
||||
#else
|
||||
return os_handle_list_alloc(arena_allocator(arena), handles, handle);
|
||||
os_handle_list_alloc(arena_allocator(arena), handles, handle);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -220,6 +206,17 @@ os_handle_array_from_list_alloc(AllocatorInfo ainfo, OS_HandleList* list) {
|
||||
////////////////////////////////
|
||||
//~ rjf: Command Line Argc/Argv Helper (Helper, Implemented Once)
|
||||
|
||||
inline String8List
|
||||
os_string_list_from_argcv_alloc(AllocatorInfo ainfo, int argc, char** argv) {
|
||||
String8List result = {0};
|
||||
for(int i = 0; i < argc; i += 1)
|
||||
{
|
||||
String8 str = str8_cstring(argv[i]);
|
||||
str8_list_alloc(ainfo, &result, str);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline String8List
|
||||
os_string_list_from_argcv(Arena* arena, int argc, char** argv) {
|
||||
String8List result = {0};
|
||||
@@ -231,16 +228,36 @@ os_string_list_from_argcv(Arena* arena, int argc, char** argv) {
|
||||
return result;
|
||||
}
|
||||
|
||||
inline String8List
|
||||
os_string_list_from_argcv(AllocatorInfo ainfo, int argc, char** argv) {
|
||||
String8List result = {0};
|
||||
for(int i = 0; i < argc; i += 1)
|
||||
{
|
||||
String8 str = str8_cstring(argv[i]);
|
||||
str8_list_alloc(ainfo, &result, str);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks File System (Implemented Per-OS)
|
||||
|
||||
//- rjf: files
|
||||
MD_API OS_Handle os_file_open (OS_AccessFlags flags, String8 path);
|
||||
MD_API void os_file_close (OS_Handle file);
|
||||
MD_API U64 os_file_read (OS_Handle file, Rng1U64 rng, void *out_data);
|
||||
MD_API U64 os_file_write (OS_Handle file, Rng1U64 rng, void *data);
|
||||
MD_API B32 os_file_set_times (OS_Handle file, DateTime time);
|
||||
MD_API FileProperties os_properties_from_file (OS_Handle file);
|
||||
MD_API OS_FileID os_id_from_file (OS_Handle file);
|
||||
MD_API B32 os_delete_file_at_path (String8 path);
|
||||
MD_API B32 os_copy_file_path (String8 dst, String8 src);
|
||||
MD_API String8 os_full_path_from_path (Arena* arena, String8 path);
|
||||
MD_API B32 os_file_path_exists (String8 path);
|
||||
MD_API FileProperties os_properties_from_file_path(String8 path);
|
||||
|
||||
//- rjf: file maps
|
||||
MD_API OS_Handle os_file_map_open (OS_AccessFlags flags, OS_Handle file);
|
||||
MD_API void os_file_map_close (OS_Handle map);
|
||||
MD_API void* os_file_map_view_open (OS_Handle map, OS_AccessFlags flags, Rng1U64 range);
|
||||
MD_API void os_file_map_view_close(OS_Handle map, void* ptr, Rng1U64 range);
|
||||
|
||||
//- rjf: directory iteration
|
||||
MD_API OS_FileIter* os_file_iter_begin(Arena* arena, String8 path, OS_FileIterFlags flags);
|
||||
MD_API B32 os_file_iter_next (Arena* arena, OS_FileIter* iter, OS_FileInfo* info_out);
|
||||
MD_API void os_file_iter_end ( OS_FileIter* iter);
|
||||
|
||||
//- rjf: directory creation
|
||||
MD_API B32 os_make_directory(String8 path);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Filesystem Helpers (Helpers, Implemented Once)
|
||||
@@ -295,8 +312,8 @@ inline S64 os_file_id_compare(OS_FileID a, OS_FileID b) { S64 cmp = memory_compa
|
||||
//~ rjf: GUID Helpers (Helpers, Implemented Once)
|
||||
|
||||
inline String8
|
||||
os_string_from_guid(Arena* arena, OS_Guid guid) {
|
||||
String8 result = push_str8f(arena,
|
||||
os_string_from_guid_alloc(AllocatorInfo ainfo, OS_Guid guid) {
|
||||
String8 result = alloc_str8f(ainfo,
|
||||
"%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
||||
guid.data1,
|
||||
guid.data2,
|
||||
@@ -314,8 +331,8 @@ os_string_from_guid(Arena* arena, OS_Guid guid) {
|
||||
}
|
||||
|
||||
inline String8
|
||||
os_string_from_guid(AllocatorInfo ainfo, OS_Guid guid) {
|
||||
String8 result = alloc_str8f(ainfo,
|
||||
os_string_from_guid(Arena* arena, OS_Guid guid) {
|
||||
String8 result = push_str8f(arena,
|
||||
"%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
||||
guid.data1,
|
||||
guid.data2,
|
||||
@@ -364,37 +381,6 @@ MD_API void os_set_thread_name(String8 string);
|
||||
|
||||
MD_API void os_abort(S32 exit_code);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks File System (Implemented Per-OS)
|
||||
|
||||
//- rjf: files
|
||||
MD_API OS_Handle os_file_open (OS_AccessFlags flags, String8 path);
|
||||
MD_API void os_file_close (OS_Handle file);
|
||||
MD_API U64 os_file_read (OS_Handle file, Rng1U64 rng, void *out_data);
|
||||
MD_API U64 os_file_write (OS_Handle file, Rng1U64 rng, void *data);
|
||||
MD_API B32 os_file_set_times (OS_Handle file, DateTime time);
|
||||
MD_API FileProperties os_properties_from_file (OS_Handle file);
|
||||
MD_API OS_FileID os_id_from_file (OS_Handle file);
|
||||
MD_API B32 os_delete_file_at_path (String8 path);
|
||||
MD_API B32 os_copy_file_path (String8 dst, String8 src);
|
||||
MD_API String8 os_full_path_from_path (Arena* arena, String8 path);
|
||||
MD_API B32 os_file_path_exists (String8 path);
|
||||
MD_API FileProperties os_properties_from_file_path(String8 path);
|
||||
|
||||
//- rjf: file maps
|
||||
MD_API OS_Handle os_file_map_open (OS_AccessFlags flags, OS_Handle file);
|
||||
MD_API void os_file_map_close (OS_Handle map);
|
||||
MD_API void* os_file_map_view_open (OS_Handle map, OS_AccessFlags flags, Rng1U64 range);
|
||||
MD_API void os_file_map_view_close(OS_Handle map, void* ptr, Rng1U64 range);
|
||||
|
||||
//- rjf: directory iteration
|
||||
MD_API OS_FileIter* os_file_iter_begin(Arena* arena, String8 path, OS_FileIterFlags flags);
|
||||
MD_API B32 os_file_iter_next (Arena* arena, OS_FileIter* iter, OS_FileInfo* info_out);
|
||||
MD_API void os_file_iter_end ( OS_FileIter* iter);
|
||||
|
||||
//- rjf: directory creation
|
||||
MD_API B32 os_make_directory(String8 path);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Shared Memory (Implemented Per-OS)
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifdef INTELLISENSE_DIRECTIVES
|
||||
# include "base/context_cracking.h"
|
||||
# include "base/namespace.h"
|
||||
#endif
|
||||
|
||||
#if !defined(OS_FEATURE_GRAPHICAL)
|
||||
# define OS_FEATURE_GRAPHICAL 0
|
||||
#endif
|
||||
|
||||
#if !defined(OS_GFX_STUB)
|
||||
# define OS_GFX_STUB 0
|
||||
#endif
|
||||
|
||||
#if OS_WINDOWS
|
||||
# include "os/win32/os_win32_includes.h"
|
||||
|
||||
MD_NS_BEGIN
|
||||
# include "os/win32/os_win32.h"
|
||||
MD_NS_END
|
||||
|
||||
#elif OS_LINUX
|
||||
# include "os/linux/os_linux_includes.h"
|
||||
|
||||
MD_NS_BEGIN
|
||||
# include "os/linux/os_linux.h"
|
||||
MD_NS_END
|
||||
# error OS core layer not implemented for this operating system.
|
||||
#endif
|
||||
+41
-65
@@ -1,39 +1,14 @@
|
||||
#ifdef INTELLISENSE_DIRECTIVES
|
||||
# pragma once
|
||||
# include "base/base.h"
|
||||
# include "base/strings.h"
|
||||
# include "base/thread_context.h"
|
||||
# include "os.h"
|
||||
# include "os_win32_includes.h"
|
||||
#endif
|
||||
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Includes / Libraries
|
||||
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_MEAN_AND_LEAN
|
||||
#define VC_EXTRALEAN
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <timeapi.h>
|
||||
#include <tlhelp32.h>
|
||||
#include <Shlobj.h>
|
||||
#include <processthreadsapi.h>
|
||||
#pragma comment(lib, "user32")
|
||||
#pragma comment(lib, "winmm")
|
||||
#pragma comment(lib, "shell32")
|
||||
#pragma comment(lib, "advapi32")
|
||||
#pragma comment(lib, "rpcrt4")
|
||||
#pragma comment(lib, "shlwapi")
|
||||
#pragma comment(lib, "comctl32")
|
||||
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") // this is required for loading correct comctl32 dll file
|
||||
#undef NOMINMAX
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#undef WIN32_MEAN_AND_LEAN
|
||||
#undef VC_EXTRALEAN
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: File Iterator Types
|
||||
|
||||
@@ -108,26 +83,6 @@ struct OS_W32_State
|
||||
|
||||
MD_API extern OS_W32_State os_w32_state = {0};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: File Info Conversion Helpers
|
||||
|
||||
inline FilePropertyFlags
|
||||
os_w32_file_property_flags_from_dwFileAttributes(DWORD dwFileAttributes)
|
||||
{
|
||||
FilePropertyFlags flags = 0;
|
||||
if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
flags |= FilePropertyFlag_IsFolder;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
inline void
|
||||
os_w32_file_properties_from_attribute_data(FileProperties* properties, WIN32_FILE_ATTRIBUTE_DATA* attributes) {
|
||||
properties->size = compose_64bit(attributes->nFileSizeHigh, attributes->nFileSizeLow);
|
||||
os_w32_dense_time_from_file_time(&properties->created, &attributes->ftCreationTime);
|
||||
os_w32_dense_time_from_file_time(&properties->modified, &attributes->ftLastWriteTime);
|
||||
properties->flags = os_w32_file_property_flags_from_dwFileAttributes(attributes->dwFileAttributes);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Time Conversion Helpers
|
||||
@@ -173,6 +128,27 @@ os_w32_dense_time_from_file_time(DenseTime* out, FILETIME* in) {
|
||||
*out = dense_time_from_date_time(date_time);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: File Info Conversion Helpers
|
||||
|
||||
inline FilePropertyFlags
|
||||
os_w32_file_property_flags_from_dwFileAttributes(DWORD dwFileAttributes)
|
||||
{
|
||||
FilePropertyFlags flags = 0;
|
||||
if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
flags |= FilePropertyFlag_IsFolder;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
inline void
|
||||
os_w32_file_properties_from_attribute_data(FileProperties* properties, WIN32_FILE_ATTRIBUTE_DATA* attributes) {
|
||||
properties->size = compose_64bit(attributes->nFileSizeHigh, attributes->nFileSizeLow);
|
||||
os_w32_dense_time_from_file_time(&properties->created, &attributes->ftCreationTime);
|
||||
os_w32_dense_time_from_file_time(&properties->modified, &attributes->ftLastWriteTime);
|
||||
properties->flags = os_w32_file_property_flags_from_dwFileAttributes(attributes->dwFileAttributes);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Entity Functions
|
||||
|
||||
@@ -188,21 +164,7 @@ MD_API DWORD os_w32_thread_entry_point(void* ptr);
|
||||
//~ rjf: @os_hooks System/Process Info (Implemented Per-OS)
|
||||
|
||||
inline String8
|
||||
os_get_current_path(Arena* arena) {
|
||||
String8 name;
|
||||
TempArena scratch = scratch_begin(&arena, 1);
|
||||
{
|
||||
DWORD length = GetCurrentDirectoryW(0, 0);
|
||||
U16* memory = push_array_no_zero(scratch.arena, U16, length + 1);
|
||||
length = GetCurrentDirectoryW(length + 1, (WCHAR*)memory);
|
||||
name = str8_from_16(arena, str16(memory, length));
|
||||
}
|
||||
scratch_end(scratch);
|
||||
return name;
|
||||
}
|
||||
|
||||
inline String8
|
||||
os_get_current_path(AllocatorInfo ainfo) {
|
||||
os_get_current_path_alloc(AllocatorInfo ainfo) {
|
||||
String8 name;
|
||||
// TODO(Ed): Review
|
||||
TempArena scratch = scratch_begin(0, 0);
|
||||
@@ -216,6 +178,20 @@ os_get_current_path(AllocatorInfo ainfo) {
|
||||
return name;
|
||||
}
|
||||
|
||||
inline String8
|
||||
os_get_current_path(Arena* arena) {
|
||||
String8 name;
|
||||
TempArena scratch = scratch_begin(&arena, 1);
|
||||
{
|
||||
DWORD length = GetCurrentDirectoryW(0, 0);
|
||||
U16* memory = push_array_no_zero(scratch.arena, U16, length + 1);
|
||||
length = GetCurrentDirectoryW(length + 1, (WCHAR*)memory);
|
||||
name = str8_from_16(arena, str16(memory, length));
|
||||
}
|
||||
scratch_end(scratch);
|
||||
return name;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Memory Allocation (Implemented Per-OS)
|
||||
|
||||
@@ -240,7 +216,7 @@ os_reserve_large(U64 size) {
|
||||
return result;
|
||||
}
|
||||
|
||||
inline B32 os_commit_large(void *ptr, U64 size) { return 1; }
|
||||
inline B32 os_commit_large(void* ptr, U64 size) { return 1; }
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Thread Info (Implemented Per-OS)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifdef INTELLISENSE_DIRECTIVES
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Includes / Libraries
|
||||
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_MEAN_AND_LEAN
|
||||
#define VC_EXTRALEAN
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <timeapi.h>
|
||||
#include <tlhelp32.h>
|
||||
#include <Shlobj.h>
|
||||
#include <processthreadsapi.h>
|
||||
#pragma comment(lib, "user32")
|
||||
#pragma comment(lib, "winmm")
|
||||
#pragma comment(lib, "shell32")
|
||||
#pragma comment(lib, "advapi32")
|
||||
#pragma comment(lib, "rpcrt4")
|
||||
#pragma comment(lib, "shlwapi")
|
||||
#pragma comment(lib, "comctl32")
|
||||
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") // this is required for loading correct comctl32 dll file
|
||||
#undef NOMINMAX
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#undef WIN32_MEAN_AND_LEAN
|
||||
#undef VC_EXTRALEAN
|
||||
@@ -737,12 +737,12 @@ The @code node_count and @code total_size are automatically maintained by the he
|
||||
@see(MD_Token)
|
||||
@see(MD_TokenFromString)
|
||||
@prefix(MD_TokenGroup)
|
||||
@flags MD_TokenGroups:
|
||||
@flags MD_TokenFlagGroups:
|
||||
{
|
||||
Comment: `MD_TokenKind_Comment`,
|
||||
Whitespace: `(MD_TokenKind_Whitespace|MD_TokenKind_Newline)`,
|
||||
Irregular: `(MD_TokenGroup_Comment|MD_TokenGroup_Whitespace)`,
|
||||
Regular: `~MD_TokenGroup_Irregular`,
|
||||
Irregular: `(MD_TokenFlagGroup_Comment|MD_TokenFlagGroup_Whitespace)`,
|
||||
Regular: `~MD_TokenFlagGroup_Irregular`,
|
||||
Label: `(MD_TokenKind_Identifier|MD_TokenKind_Numeric|MD_TokenKind_StringLiteral|MD_TokenKind_Symbol)`,
|
||||
Error: `(MD_TokenKind_BrokenComment|MD_TokenKind_BrokenStringLiteral|MD_TokenKind_BadCharacter)`,
|
||||
}
|
||||
|
||||
@@ -1018,8 +1018,8 @@ word MsgList, MD_MsgList
|
||||
|
||||
word TokenFlags, MD_MsgFlags
|
||||
namespace TokenFlag_, MD_TokenFlag_
|
||||
word TokenGroups, MD_TokenGroups
|
||||
namespace TokenGroup_, MD_TokenGroup_
|
||||
word TokenFlagGroups, MD_TokenFlagGroups
|
||||
namespace TokenFlagGroup_, MD_TokenFlagGroup_
|
||||
word Token, MD_Token
|
||||
word TokenChunkNode, MD_TokenChunkNode
|
||||
word TokenChunkList, MD_TokenChunkList
|
||||
|
||||
+13
-13
@@ -2387,7 +2387,7 @@ MD_ParseNodeSet(MD_Arena *arena, MD_String8 string, MD_u64 offset, Node *parent,
|
||||
case MD_ParseSetRule_EndOnDelimiter:
|
||||
{
|
||||
MD_u64 opener_check_off = off;
|
||||
opener_check_off += MD_LexAdvanceFromSkips(MD_S8Skip(string, opener_check_off), TokenGroup_Irregular);
|
||||
opener_check_off += MD_LexAdvanceFromSkips(MD_S8Skip(string, opener_check_off), TokenFlagGroup_Irregular);
|
||||
initial_token = MD_TokenFromString(MD_S8Skip(string, opener_check_off));
|
||||
if(initial_token.kind == MD_TokenKind_Reserved)
|
||||
{
|
||||
@@ -2486,7 +2486,7 @@ MD_ParseNodeSet(MD_Arena *arena, MD_String8 string, MD_u64 offset, Node *parent,
|
||||
|
||||
//- rjf: check separators and possible braces from higher parents
|
||||
{
|
||||
closer_check_off += MD_LexAdvanceFromSkips(MD_S8Skip(string, off), TokenGroup_Irregular);
|
||||
closer_check_off += MD_LexAdvanceFromSkips(MD_S8Skip(string, off), TokenFlagGroup_Irregular);
|
||||
Token potential_closer = MD_TokenFromString(MD_S8Skip(string, closer_check_off));
|
||||
if(potential_closer.kind == MD_TokenKind_Reserved)
|
||||
{
|
||||
@@ -2510,7 +2510,7 @@ MD_ParseNodeSet(MD_Arena *arena, MD_String8 string, MD_u64 offset, Node *parent,
|
||||
if(!close_with_separator && !parse_all)
|
||||
{
|
||||
MD_u64 closer_check_off = off;
|
||||
closer_check_off += MD_LexAdvanceFromSkips(MD_S8Skip(string, off), TokenGroup_Irregular);
|
||||
closer_check_off += MD_LexAdvanceFromSkips(MD_S8Skip(string, off), TokenFlagGroup_Irregular);
|
||||
Token potential_closer = MD_TokenFromString(MD_S8Skip(string, closer_check_off));
|
||||
if(potential_closer.kind == MD_TokenKind_Reserved)
|
||||
{
|
||||
@@ -2574,7 +2574,7 @@ MD_ParseNodeSet(MD_Arena *arena, MD_String8 string, MD_u64 offset, Node *parent,
|
||||
NodeFlags trailing_separator_flags = 0;
|
||||
if(!close_with_separator)
|
||||
{
|
||||
off += MD_LexAdvanceFromSkips(MD_S8Skip(string, off), TokenGroup_Irregular);
|
||||
off += MD_LexAdvanceFromSkips(MD_S8Skip(string, off), TokenFlagGroup_Irregular);
|
||||
Token trailing_separator = MD_TokenFromString(MD_S8Skip(string, off));
|
||||
if (trailing_separator.kind == MD_TokenKind_Reserved)
|
||||
{
|
||||
@@ -2659,7 +2659,7 @@ MD_ParseOneNode(MD_Arena *arena, MD_String8 string, MD_u64 offset)
|
||||
MD_MemoryZeroStruct(&comment_token);
|
||||
}
|
||||
}
|
||||
else if((token.kind & TokenGroup_Whitespace) != 0)
|
||||
else if((token.kind & TokenFlagGroup_Whitespace) != 0)
|
||||
{
|
||||
off += token.raw_string.size;
|
||||
}
|
||||
@@ -2678,7 +2678,7 @@ MD_ParseOneNode(MD_Arena *arena, MD_String8 string, MD_u64 offset)
|
||||
for(;off < string.size;)
|
||||
{
|
||||
//- rjf: parse @ symbol, signifying start of tag
|
||||
off += MD_LexAdvanceFromSkips(MD_S8Skip(string, off), TokenGroup_Irregular);
|
||||
off += MD_LexAdvanceFromSkips(MD_S8Skip(string, off), TokenFlagGroup_Irregular);
|
||||
Token next_token = MD_TokenFromString(MD_S8Skip(string, off));
|
||||
if(next_token.kind != MD_TokenKind_Reserved ||
|
||||
next_token.string.str[0] != '@')
|
||||
@@ -2690,7 +2690,7 @@ MD_ParseOneNode(MD_Arena *arena, MD_String8 string, MD_u64 offset)
|
||||
//- rjf: parse string of tag node
|
||||
Token name = MD_TokenFromString(MD_S8Skip(string, off));
|
||||
MD_u64 name_off = off;
|
||||
if((name.kind & TokenGroup_Label) == 0)
|
||||
if((name.kind & TokenFlagGroup_Label) == 0)
|
||||
{
|
||||
// NOTE(rjf): @error Improper token for tag string
|
||||
MD_String8 error_str = MD_S8Fmt(arena, "\"%.*s\" is not a proper tag label",
|
||||
@@ -2726,7 +2726,7 @@ MD_ParseOneNode(MD_Arena *arena, MD_String8 string, MD_u64 offset)
|
||||
retry:;
|
||||
{
|
||||
//- rjf: try to parse an unnamed set
|
||||
off += MD_LexAdvanceFromSkips(MD_S8Skip(string, off), TokenGroup_Irregular);
|
||||
off += MD_LexAdvanceFromSkips(MD_S8Skip(string, off), TokenFlagGroup_Irregular);
|
||||
Token unnamed_set_opener = MD_TokenFromString(MD_S8Skip(string, off));
|
||||
if(unnamed_set_opener.kind == MD_TokenKind_Reserved)
|
||||
{
|
||||
@@ -2763,9 +2763,9 @@ MD_ParseOneNode(MD_Arena *arena, MD_String8 string, MD_u64 offset)
|
||||
}
|
||||
|
||||
//- rjf: try to parse regular node, with/without children
|
||||
off += MD_LexAdvanceFromSkips(MD_S8Skip(string, off), TokenGroup_Irregular);
|
||||
off += MD_LexAdvanceFromSkips(MD_S8Skip(string, off), TokenFlagGroup_Irregular);
|
||||
Token label_name = MD_TokenFromString(MD_S8Skip(string, off));
|
||||
if((label_name.kind & TokenGroup_Label) != 0)
|
||||
if((label_name.kind & TokenFlagGroup_Label) != 0)
|
||||
{
|
||||
off += label_name.raw_string.size;
|
||||
parsed_node = MD_MakeNode(arena, NodeKind_Main, label_name.string, label_name.raw_string,
|
||||
@@ -2774,7 +2774,7 @@ MD_ParseOneNode(MD_Arena *arena, MD_String8 string, MD_u64 offset)
|
||||
|
||||
//- rjf: try to parse children for this node
|
||||
MD_u64 colon_check_off = off;
|
||||
colon_check_off += MD_LexAdvanceFromSkips(MD_S8Skip(string, colon_check_off), TokenGroup_Irregular);
|
||||
colon_check_off += MD_LexAdvanceFromSkips(MD_S8Skip(string, colon_check_off), TokenFlagGroup_Irregular);
|
||||
Token colon = MD_TokenFromString(MD_S8Skip(string, colon_check_off));
|
||||
if(colon.kind == MD_TokenKind_Reserved &&
|
||||
colon.string.str[0] == ':')
|
||||
@@ -2792,7 +2792,7 @@ MD_ParseOneNode(MD_Arena *arena, MD_String8 string, MD_u64 offset)
|
||||
|
||||
//- rjf: collect bad token
|
||||
Token bad_token = MD_TokenFromString(MD_S8Skip(string, off));
|
||||
if(bad_token.kind & TokenGroup_Error)
|
||||
if(bad_token.kind & TokenFlagGroup_Error)
|
||||
{
|
||||
off += bad_token.raw_string.size;
|
||||
|
||||
@@ -2859,7 +2859,7 @@ MD_ParseOneNode(MD_Arena *arena, MD_String8 string, MD_u64 offset)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if((token.kind & TokenGroup_Whitespace) != 0)
|
||||
else if((token.kind & TokenFlagGroup_Whitespace) != 0)
|
||||
{
|
||||
off += token.raw_string.size;
|
||||
}
|
||||
|
||||
+8
-8
@@ -707,20 +707,20 @@ enum
|
||||
MD_TokenKind_BadCharacter = (1<<10),
|
||||
};
|
||||
|
||||
typedef MD_u32 MD_TokenGroups;
|
||||
typedef MD_u32 MD_TokenFlagGroups;
|
||||
enum
|
||||
{
|
||||
TokenGroup_Comment = MD_TokenKind_Comment,
|
||||
TokenGroup_Whitespace = (MD_TokenKind_Whitespace|
|
||||
TokenFlagGroup_Comment = MD_TokenKind_Comment,
|
||||
TokenFlagGroup_Whitespace = (MD_TokenKind_Whitespace|
|
||||
MD_TokenKind_Newline),
|
||||
TokenGroup_Irregular = (TokenGroup_Comment|
|
||||
TokenGroup_Whitespace),
|
||||
TokenGroup_Regular = ~TokenGroup_Irregular,
|
||||
TokenGroup_Label = (MD_TokenKind_Identifier|
|
||||
TokenFlagGroup_Irregular = (TokenFlagGroup_Comment|
|
||||
TokenFlagGroup_Whitespace),
|
||||
TokenFlagGroup_Regular = ~TokenFlagGroup_Irregular,
|
||||
TokenFlagGroup_Label = (MD_TokenKind_Identifier|
|
||||
MD_TokenKind_Numeric|
|
||||
MD_TokenKind_StringLiteral|
|
||||
MD_TokenKind_Symbol),
|
||||
TokenGroup_Error = (MD_TokenKind_BrokenComment|
|
||||
TokenFlagGroup_Error = (MD_TokenKind_BrokenComment|
|
||||
MD_TokenKind_BrokenStringLiteral|
|
||||
MD_TokenKind_BadCharacter),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user