Browse Source

update

master
Daniel Ledda 3 weeks ago
parent
commit
27e7d74895
2 changed files with 21 additions and 3 deletions
  1. +15
    -0
      core.c
  2. +6
    -3
      core.h

+ 15
- 0
core.c View File

@@ -423,3 +423,18 @@ int intCompare(const void *a, const void *b) {
return (*x > *y) - (*x < *y);
}


#ifdef DJSTD_BASIC_ENTRY
int djstd_entry(Arena* arena, StringList args);

#ifndef DJSTD_BASIC_ENTRY_ARENA_ALLOC
#define DJSTD_BASIC_ENTRY_ARENA_ALLOC Megabytes(64)
#endif

int main(int argc, char **argv) {
initialiseDjStdCore();
Arena *arena = arenaAlloc(DJSTD_BASIC_ENTRY_ARENA_ALLOC);
StringList args = getArgs(arena, argc, argv);
return djstd_entry(arena, args);
}
#endif

+ 6
- 3
core.h View File

@@ -136,17 +136,20 @@ inline function Vec4 vec4(real32 x, real32 y, real32 z, real32 w) {
type* data;\
size_t length;\
size_t capacity;\
} prefix ## List
} prefix ## List;\
typedef type prefix ## List ## _underlying
#define ListElementSize(list) MemberSizeUnderlying(list, data)

DefineList(string, String);

#define PushList(arena, type, size) (type){ pushSize(arena, ListElementSize(type)*size), 0, size }
#define EmptyList(type) (type){ NULL, 0, 0 }
#define PushListZero(arena, type, size) (type){ pushSizeFill(arena, ListElementSize(type)*size, 0), 0, size }
#define PushFullList(arena, type, size) (type){ pushSize(arena, ListElementSize(type)*size), size, size }
#define PushFullListZero(arena, type, size) (type){ pushSizeFill(arena, ListElementSize(type)*size, 0), size, size }
#define ArrayAsList(type, array) (type){ array, ArrayCount(array), ArrayCount(array) }

#define EmptyList() { NULL, 0, 0 }
#define __ArrayAsList(array) { .data=(array), .length=ArrayCount(array), .capacity=ArrayCount(array) }
#define AsList(listtype, ...) (listtype)__ArrayAsList(((listtype##_underlying[])__VA_ARGS__))

#define AppendList(list, element) \
if ((list)->length < (list)->capacity) { \


Loading…
Cancel
Save