remove static aliases, some list helpers
This commit is contained in:
18
core.c
18
core.c
@@ -221,7 +221,7 @@ bool strContains(string str, string search) {
|
||||
}
|
||||
|
||||
string NUMERIC_CHARS = s("0123456789");
|
||||
inline function bool isNumeric(char c) {
|
||||
inline static bool isNumeric(char c) {
|
||||
return strContainsChar(NUMERIC_CHARS, c);
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ Timestamp timestampFromUnixTime(UnixTimestamp *unixTimestamp) {
|
||||
}
|
||||
|
||||
string formatTimeHmsUnix(Arena *arena, UnixTimestamp time) {
|
||||
local_persist const string format = s("HH-MM-SS");
|
||||
static const string format = s("HH-MM-SS");
|
||||
string buf = PushString(arena, format.length);
|
||||
struct tm *timestamp = gmtime((time_t *)&time);
|
||||
strftime(buf.str, buf.length + 1, "%T", timestamp);
|
||||
@@ -360,14 +360,14 @@ string formatTimeHmsUnix(Arena *arena, UnixTimestamp time) {
|
||||
}
|
||||
|
||||
string formatTimeHms(Arena *arena, Timestamp *time) {
|
||||
local_persist const string format = s("HH-MM-SS");
|
||||
static const string format = s("HH-MM-SS");
|
||||
string buf = PushString(arena, format.length);
|
||||
strftime(buf.str, buf.length + 1, "%T", (struct tm *)time);
|
||||
return buf;
|
||||
}
|
||||
|
||||
string formatTimeYmdUnix(Arena *arena, UnixTimestamp time) {
|
||||
local_persist const string format = s("YYYY-mm-dd");
|
||||
static const string format = s("YYYY-mm-dd");
|
||||
string buf = PushString(arena, format.length);
|
||||
struct tm *timestamp = gmtime((time_t *)&time);
|
||||
strftime(buf.str, buf.length + 1, "%Y-%m-%d", timestamp);
|
||||
@@ -375,34 +375,34 @@ string formatTimeYmdUnix(Arena *arena, UnixTimestamp time) {
|
||||
}
|
||||
|
||||
string formatTimeYmd(Arena *arena, Timestamp *time) {
|
||||
local_persist const string format = s("YYYY-mm-dd");
|
||||
static const string format = s("YYYY-mm-dd");
|
||||
string buf = PushString(arena, format.length);
|
||||
strftime(buf.str, buf.length + 1, "%Y-%m-%d", (struct tm *)time);
|
||||
return buf;
|
||||
}
|
||||
|
||||
function void printStderr(const char *fmt, ...) {
|
||||
static void printStderr(const char *fmt, ...) {
|
||||
va_list argList;
|
||||
va_start(argList, fmt);
|
||||
os_print(StdStream_stdout, fmt, argList);
|
||||
va_end(argList);
|
||||
}
|
||||
|
||||
function void printlnStderr(const char *fmt, ...) {
|
||||
static void printlnStderr(const char *fmt, ...) {
|
||||
va_list argList;
|
||||
va_start(argList, fmt);
|
||||
os_println(StdStream_stdout, fmt, argList);
|
||||
va_end(argList);
|
||||
}
|
||||
|
||||
function void printStdout(const char *fmt, ...) {
|
||||
static void printStdout(const char *fmt, ...) {
|
||||
va_list argList;
|
||||
va_start(argList, fmt);
|
||||
os_print(StdStream_stdout, fmt, argList);
|
||||
va_end(argList);
|
||||
}
|
||||
|
||||
function void printlnStdout(const char *fmt, ...) {
|
||||
static void printlnStdout(const char *fmt, ...) {
|
||||
va_list argList;
|
||||
va_start(argList, fmt);
|
||||
os_println(StdStream_stdout, fmt, argList);
|
||||
|
||||
20
core.h
20
core.h
@@ -14,9 +14,6 @@
|
||||
#define Assert(expression)
|
||||
#endif
|
||||
|
||||
#define function static
|
||||
#define global static
|
||||
#define local_persist static
|
||||
#define Forever for (;;)
|
||||
|
||||
#define DeferLoop(begin_stmnt, end_stmnt) for(int __defer_i = ((begin_stmnt), 0); __defer_i < 1; (++__defer_i, (end_stmnt)))
|
||||
@@ -91,7 +88,7 @@ union Vec2 {
|
||||
};
|
||||
real32 vec[2];
|
||||
};
|
||||
inline function Vec2 vec2(real32 x, real32 y) {
|
||||
inline Vec2 vec2(real32 x, real32 y) {
|
||||
Vec2 result = {0};
|
||||
result.x = x;
|
||||
result.y = y;
|
||||
@@ -107,7 +104,7 @@ union Vec3 {
|
||||
};
|
||||
real32 vec[3];
|
||||
};
|
||||
inline function Vec3 vec3(real32 x, real32 y, real32 z) {
|
||||
inline Vec3 vec3(real32 x, real32 y, real32 z) {
|
||||
Vec3 result = {0};
|
||||
result.x = x;
|
||||
result.y = y;
|
||||
@@ -131,7 +128,7 @@ union Vec4 {
|
||||
};
|
||||
real32 vec[4];
|
||||
};
|
||||
inline function Vec4 vec4(real32 x, real32 y, real32 z, real32 w) {
|
||||
inline Vec4 vec4(real32 x, real32 y, real32 z, real32 w) {
|
||||
Vec4 result = {0};
|
||||
result.x = x;
|
||||
result.y = y;
|
||||
@@ -169,11 +166,11 @@ void *__listcopyhelper__;
|
||||
if ((list).length < (list).capacity) { \
|
||||
(list).data[(list).length++] = (element); \
|
||||
}
|
||||
#define ZeroListFull(list) memset((list)->data, 0, (list)->length * sizeof((list)->data[0]))
|
||||
#define ZeroList(list) (list)->length = 0; \
|
||||
memset((list)->data, 0, (list)->length * sizeof((list)->data[0]))
|
||||
/** 1 indicates last element, 2 second last, etc. */
|
||||
#define ListGetFromEnd(list, count) ((list).data[(list).length - (count)])
|
||||
|
||||
|
||||
#define ZeroList(list) /** Keeps the list's length and sets all memory to 0 */ memset((list).data, 0, (list).length * sizeof((list).data[0]))
|
||||
#define ClearList(list) /** Clears the list by setting all memory and the length to 0 */ (list).length = 0; memset((list).data, 0, (list).length * sizeof((list).data[0]))
|
||||
#define ListGetFromEnd(list, count) /** 1 indicates last element, 2 second last, etc. */ ((list).data[(list).length - (count)])
|
||||
#define ListLast(list) ListGetFromEnd(list, 1)
|
||||
|
||||
inline VoidList __cloneList(Arena *arena, VoidList list, size_t underlyingSize) {
|
||||
@@ -339,6 +336,7 @@ extern void (*println)(const char *fmt, ...);
|
||||
#define EachIn(list, it) size_t it = 0; it < (list).length; it++
|
||||
#define EachEl(list, type, element) type *element = (list).data; element < (list).data + (list).length; element += 1
|
||||
#define EachInReversed(list, it) size_t it = (list).length - 1; it >= 0 && it < (list).length; it--
|
||||
#define EachElReversed(list, type, element) type *element = (list).data + (list).length - 1; element >= (list).data; element -= 1
|
||||
#define EachInArray(arr, it) size_t it = 0; it < ArrayCount(arr); ++it
|
||||
|
||||
// ### Misc ###
|
||||
|
||||
Reference in New Issue
Block a user