add c and jai

This commit is contained in:
2026-07-13 13:02:47 -04:00
parent cf8342f8d4
commit c5b14d7c41
33 changed files with 6306 additions and 0 deletions

49
c/base/base_strings.h Normal file
View File

@@ -0,0 +1,49 @@
#pragma once
// base_strings.h - Simple length-delimited string type
// Inspired by raddebugger's String8
#include "base/base_core.h"
////////////////////////////////
// String types
typedef struct Str8 {
const char *str;
U64 size;
} Str8;
typedef struct Str8Node {
struct Str8Node *next;
Str8 string;
} Str8Node;
typedef struct Str8List {
Str8Node *first;
Str8Node *last;
U64 count;
U64 total_size;
} Str8List;
////////////////////////////////
// Forward declaration for Arena
typedef struct Arena Arena;
////////////////////////////////
// Constructors
static inline Str8 str8(const char *s, U64 len) { Str8 r = {s, len}; return r; }
static inline Str8 str8_cstr(const char *s) { Str8 r = {s, s ? (U64)strlen(s) : 0}; return r; }
static inline Str8 str8_lit(const char *s) { Str8 r = {s, s ? (U64)strlen(s) : 0}; return r; }
static inline B32 str8_match(Str8 a, Str8 b) {
if (a.size != b.size) return 0;
return MemoryCompare(a.str, b.str, a.size) == 0;
}
static inline B32 str8_is_empty(Str8 s) { return s.size == 0 || s.str == NULL; }
////////////////////////////////
// String operations (require arena)
Str8 str8_pushf(Arena *arena, const char *fmt, ...);
Str8 str8_push_copy(Arena *arena, Str8 s);
void str8_list_push(Arena *arena, Str8List *list, Str8 s);