]> git.lizzy.rs Git - nothing.git/commitdiff
(#594) assert -> trace_assert
authorrexim <reximkut@gmail.com>
Sat, 29 Dec 2018 17:21:39 +0000 (00:21 +0700)
committerrexim <reximkut@gmail.com>
Sat, 29 Dec 2018 17:21:39 +0000 (00:21 +0700)
42 files changed:
CMakeLists.txt
src/ebisp/builtins.c
src/ebisp/expr.c
src/ebisp/gc.c
src/ebisp/interpreter.c
src/ebisp/parser.c
src/ebisp/repl.c
src/ebisp/repl_runtime.c
src/ebisp/scope.c
src/ebisp/std.c
src/ebisp/tokenizer.c
src/game.c
src/game/camera.c
src/game/level.c
src/game/level/background.c
src/game/level/boxes.c
src/game/level/goals.c
src/game/level/labels.c
src/game/level/lava.c
src/game/level/lava/wavy_rect.c
src/game/level/physical_world.c
src/game/level/platforms.c
src/game/level/player.c
src/game/level/player/dying_rect.c
src/game/level/player/rigid_rect.c
src/game/level/regions.c
src/game/level/script.c
src/game/level_script.c
src/game/sound_samples.c
src/game/sprite_font.c
src/math/point.c
src/math/rect.c
src/sdl/renderer.c
src/str.c
src/system/line_stream.c
src/system/log_script.c
src/system/lt.c
src/system/lt/lt_slot.c
src/ui/console.c
src/ui/console_log.c
src/ui/edit_field.c
src/ui/history.c

index 7fb04e603d27d1631785604d8da3b85354f9b0d4..9aeb187ace521dfe01e14da02654bb2208d46336 100644 (file)
@@ -155,6 +155,8 @@ add_executable(repl
   src/ebisp/repl_runtime.c
   src/ebisp/std.h
   src/ebisp/std.c
+  src/system/stacktrace.h
+  src/system/stacktrace.c
   )
 add_executable(nothing_test
   src/ebisp/builtins.c
@@ -186,6 +188,8 @@ add_executable(nothing_test
   src/system/log.c
   src/system/nth_alloc.h
   src/system/nth_alloc.c
+  src/system/stacktrace.h
+  src/system/stacktrace.c
   )
 target_link_libraries(nothing ${SDL2_LIBRARY} ${SDL2_MIXER_LIBRARY} m)
 target_link_libraries(nothing_test ${SDL2_LIBRARY} ${SDL2_MIXER_LIBRARY} m)
index e5c040f6a8cb4285eb49b5766ad9d832b5a5bcc5..14d528f59a09c4c2f481439785b0694049c43206 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <math.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -9,8 +9,8 @@
 
 static bool equal_atoms(struct Atom *atom1, struct Atom *atom2)
 {
-    assert(atom1);
-    assert(atom2);
+    trace_assert(atom1);
+    trace_assert(atom2);
 
     if (atom1->type != atom2->type) {
         return false;
@@ -36,8 +36,8 @@ static bool equal_atoms(struct Atom *atom1, struct Atom *atom2)
 
 static bool equal_cons(struct Cons *cons1, struct Cons *cons2)
 {
-    assert(cons1);
-    assert(cons2);
+    trace_assert(cons1);
+    trace_assert(cons2);
     return equal(cons1->car, cons2->car) && equal(cons1->cdr, cons2->cdr);
 }
 
@@ -180,7 +180,7 @@ const char *specials[] = {
 
 bool is_special(const char *name)
 {
-    assert(name);
+    trace_assert(name);
 
     size_t n = sizeof(specials) / sizeof(const char*);
     for (size_t i = 0; i < n; ++i) {
@@ -196,8 +196,8 @@ bool is_special(const char *name)
 static struct Expr
 list_rec(Gc *gc, const char *format, va_list args)
 {
-    assert(gc);
-    assert(format);
+    trace_assert(gc);
+    trace_assert(format);
 
     if (*format == 0) {
         return NIL(gc);
@@ -229,7 +229,7 @@ list_rec(Gc *gc, const char *format, va_list args)
 
     default: {
         fprintf(stderr, "Wrong format parameter: %c\n", *format);
-        assert(0);
+        trace_assert(0);
     }
     }
 }
index d82ffee8dd5dc8a5f1fcab7e43a91a42bea1d691..16b4277df5bedae89185483cf97cc8fd13592f35 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <ctype.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -40,7 +40,7 @@ struct Expr void_expr(void)
 
 void print_atom_as_sexpr(FILE *stream, struct Atom *atom)
 {
-    assert(atom);
+    trace_assert(atom);
 
     switch (atom->type) {
     case ATOM_SYMBOL:
@@ -63,7 +63,7 @@ void print_atom_as_sexpr(FILE *stream, struct Atom *atom)
 
 void print_cons_as_sexpr(FILE *stream, struct Cons *head)
 {
-    assert(head);
+    trace_assert(head);
 
     struct Cons *cons = head;
 
@@ -266,8 +266,8 @@ void destroy_atom(struct Atom *atom)
 
 static int atom_as_sexpr(struct Atom *atom, char *output, size_t n)
 {
-    assert(atom);
-    assert(output);
+    trace_assert(atom);
+    trace_assert(output);
 
     switch (atom->type) {
     case ATOM_SYMBOL:
@@ -288,8 +288,8 @@ static int atom_as_sexpr(struct Atom *atom, char *output, size_t n)
 
 static int cons_as_sexpr(struct Cons *head, char *output, size_t n)
 {
-    assert(head);
-    assert(output);
+    trace_assert(head);
+    trace_assert(output);
 
     /* TODO(#378): cons_as_sexpr does not handle encoding errors of snprintf */
 
index cb755e236a18824b1bdeb5a60ccf553dbae5ae0e..56e9e2ca81ecab8ef4c2dcf28155f1167e924731 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -32,8 +32,8 @@ static long int value_of_expr(struct Expr expr)
 
 static int compare_exprs(const void *a, const void *b)
 {
-    assert(a);
-    assert(b);
+    trace_assert(a);
+    trace_assert(b);
 
     const long int ptr_a = value_of_expr(*(const struct Expr *)a);
     const long int ptr_b = value_of_expr(*(const struct Expr *)b);
@@ -79,7 +79,7 @@ Gc *create_gc(void)
 
 void destroy_gc(Gc *gc)
 {
-    assert(gc);
+    trace_assert(gc);
 
     for (size_t i = 0; i < gc->size; ++i) {
         destroy_expr(gc->exprs[i]);
@@ -90,7 +90,7 @@ void destroy_gc(Gc *gc)
 
 int gc_add_expr(Gc *gc, struct Expr expr)
 {
-    assert(gc);
+    trace_assert(gc);
 
     if (gc->size >= gc->capacity) {
         const size_t new_capacity = gc->capacity * 2;
@@ -113,7 +113,7 @@ int gc_add_expr(Gc *gc, struct Expr expr)
 
 static long int gc_find_expr(Gc *gc, struct Expr expr)
 {
-    assert(gc);
+    trace_assert(gc);
     (void) expr;
 
     struct Expr *result =
@@ -129,15 +129,15 @@ static long int gc_find_expr(Gc *gc, struct Expr expr)
 
 static void gc_traverse_expr(Gc *gc, struct Expr root)
 {
-    assert(gc);
-    assert(root.type != EXPR_VOID);
+    trace_assert(gc);
+    trace_assert(root.type != EXPR_VOID);
     const long int root_index = gc_find_expr(gc, root);
     /* TODO(#578): gc_traverse_expr just crashes when we try to collect already collected root */
     if (root_index < 0) {
         fprintf(stderr, "GC tried to collect something that was not registered\n");
         print_expr_as_sexpr(stderr, root);
         fprintf(stderr, "\n");
-        assert(root_index >= 0);
+        trace_assert(root_index >= 0);
     }
 
     if (gc->visited[root_index]) {
@@ -154,7 +154,7 @@ static void gc_traverse_expr(Gc *gc, struct Expr root)
 
 void gc_collect(Gc *gc, struct Expr root)
 {
-    assert(gc);
+    trace_assert(gc);
     (void) root;
 
     /* Sort gc->exprs O(nlogn) */
index f43809233beff9c9f58eeacdb6aa6fa0fcd034bc..70cb59064ad30a11d04672e2d4f9a3d79a2dbe70 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <math.h>
 #include <string.h>
 #include <stdarg.h>
@@ -182,8 +182,8 @@ static struct EvalResult eval_funcall(Gc *gc,
 
 struct EvalResult eval_block(Gc *gc, struct Scope *scope, struct Expr block)
 {
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
 
     if (!list_p(block)) {
         return wrong_argument_type(gc, "listp", block);
@@ -225,8 +225,8 @@ struct EvalResult
 car(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
     (void) param;
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
 
     struct Expr xs = NIL(gc);
 
index d2077341acd1e91664b6e752f62b2c03d127b19d..7239fef05576bcf8efe8f3151a6dc0f2a00e8574 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <ctype.h>
 #include <errno.h>
 #include <stdint.h>
@@ -201,15 +201,15 @@ static struct ParseResult parse_expr(Gc *gc, struct Token current_token)
 
 struct ParseResult read_expr_from_string(Gc *gc, const char *str)
 {
-    assert(gc);
-    assert(str);
+    trace_assert(gc);
+    trace_assert(str);
     return parse_expr(gc, next_token(str));
 }
 
 struct ParseResult read_all_exprs_from_string(Gc *gc, const char *str)
 {
-    assert(gc);
-    assert(str);
+    trace_assert(gc);
+    trace_assert(str);
 
     struct Token current_token = next_token(str);
     struct ParseResult parse_result = parse_expr(gc, current_token);
@@ -239,7 +239,7 @@ struct ParseResult read_all_exprs_from_string(Gc *gc, const char *str)
 
 struct ParseResult read_expr_from_file(Gc *gc, const char *filename)
 {
-    assert(filename);
+    trace_assert(filename);
 
     Lt *lt = create_lt();
     if (lt == NULL) {
index c59e026172938ce71b409f20639235c1e4eed930..b429014a7ad3935519e50e59ba607c2677a74e8d 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdbool.h>
 
 #include "gc.h"
index ff637572502093e6a279702503e4adbe5ea3cc92..8e08fe724bbede8200a5c473410a2e3e97c6365c 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 
 #include "scope.h"
 #include "interpreter.h"
@@ -8,8 +8,8 @@
 
 static struct EvalResult gc_inspect_adapter(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
     (void) param;
     (void) args;
 
@@ -20,8 +20,8 @@ static struct EvalResult gc_inspect_adapter(void *param, Gc *gc, struct Scope *s
 
 static struct EvalResult quit(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
     (void) args;
     (void) param;
 
@@ -32,8 +32,8 @@ static struct EvalResult quit(void *param, Gc *gc, struct Scope *scope, struct E
 
 static struct EvalResult get_scope(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
     (void) param;
     (void) args;
 
@@ -42,8 +42,8 @@ static struct EvalResult get_scope(void *param, Gc *gc, struct Scope *scope, str
 
 static struct EvalResult print(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
     (void) param;
 
     const char *s = NULL;
index a2cbd596cdc9736a11746ee6468071693856e49d..80c75791d49b9ff9588c991bd092a990f43e1fc3 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include "./scope.h"
 
 static struct Expr get_scope_value_impl(struct Expr scope, struct Expr name)
@@ -50,8 +50,8 @@ void set_scope_value(Gc *gc, struct Scope *scope, struct Expr name, struct Expr
 
 void push_scope_frame(Gc *gc, struct Scope *scope, struct Expr vars, struct Expr args)
 {
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
 
     struct Expr frame = NIL(gc);
 
@@ -68,8 +68,8 @@ void push_scope_frame(Gc *gc, struct Scope *scope, struct Expr vars, struct Expr
 
 void pop_scope_frame(Gc *gc, struct Scope *scope)
 {
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
 
     if (!nil_p(scope->expr)) {
         scope->expr = scope->expr.cons->cdr;
index 29de57be1b1c2cea5e35a928ec233d1414e1d374..d5f0ad186865edab918d1baa06e76d173f8fe791 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <string.h>
 
 #include "ebisp/gc.h"
@@ -20,8 +20,8 @@ static struct EvalResult
 quasiquote(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
     (void) param;
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
 
     struct Expr expr = void_expr();
     struct EvalResult result = match_list(gc, "e", args, &expr);
@@ -54,8 +54,8 @@ static struct EvalResult
 unquote(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
     (void) param;
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
     (void) args;
 
     return eval_failure(STRING(gc, "Using unquote outside of quasiquote."));
@@ -64,8 +64,8 @@ unquote(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 static struct EvalResult
 greaterThan(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
     (void) param;
 
     long int x1 = 0;
@@ -100,8 +100,8 @@ greaterThan(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 static struct EvalResult
 list_op(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
     (void) param;
 
     return eval_success(args);
@@ -111,8 +111,8 @@ static struct EvalResult
 plus_op(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
     (void) param;
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
 
     long int result = 0L;
 
@@ -136,8 +136,8 @@ static struct EvalResult
 assoc_op(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
     (void) param;
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
 
     struct Expr key = NIL(gc);
     struct Expr alist = NIL(gc);
@@ -153,8 +153,8 @@ static struct EvalResult
 set(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
     (void) param;
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
 
     const char *name = NULL;
     struct Expr value = void_expr();
@@ -177,8 +177,8 @@ static struct EvalResult
 quote(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
     (void) param;
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
 
     struct Expr expr = void_expr();
     struct EvalResult result = match_list(gc, "e", args, &expr);
@@ -193,8 +193,8 @@ static struct EvalResult
 begin(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
     (void) param;
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
 
     struct Expr block = void_expr();
     struct EvalResult result = match_list(gc, "*", args, &block);
@@ -209,8 +209,8 @@ static struct EvalResult
 defun(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
     (void) param;
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
 
     struct Expr name = void_expr();
     struct Expr args_list = void_expr();
@@ -230,8 +230,8 @@ static struct EvalResult
 when(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
     (void) param;
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
 
     struct Expr condition = void_expr();
     struct Expr body = void_expr();
@@ -258,8 +258,8 @@ static struct EvalResult
 lambda_op(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
     (void) param;
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
 
     struct Expr args_list = void_expr();
     struct Expr body = void_expr();
index 784a0656901fbfcb355bae19e11716e7482db528..3044e604bffac3f362e5e0a9d4792e6e9e974b78 100644 (file)
@@ -1,5 +1,6 @@
+#include <stdio.h>
 #include <stdbool.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <ctype.h>
 #include <stdlib.h>
 
@@ -33,7 +34,7 @@ static bool is_symbol_char(char x)
 
 static const char *skip_whitespace(const char *str)
 {
-    assert(str);
+    trace_assert(str);
 
     while(*str != 0 && isspace(*str)) {
         str++;
@@ -44,7 +45,7 @@ static const char *skip_whitespace(const char *str)
 
 static const char *next_quote(const char *str)
 {
-    assert(str);
+    trace_assert(str);
 
     while(*str != 0 && *str != '"') {
         str++;
@@ -55,7 +56,7 @@ static const char *next_quote(const char *str)
 
 static const char *skip_until_newline(const char *str)
 {
-    assert(str);
+    trace_assert(str);
 
     while(*str != 0 && *str != '\n') {
         str++;
@@ -66,7 +67,7 @@ static const char *skip_until_newline(const char *str)
 
 static const char *next_non_symbol(const char *str)
 {
-    assert(str);
+    trace_assert(str);
 
     while(*str != 0 && is_symbol_char(*str)) {
         str++;
@@ -77,7 +78,7 @@ static const char *next_non_symbol(const char *str)
 
 struct Token next_token(const char *str)
 {
-    assert(str);
+    trace_assert(str);
 
     str = skip_whitespace(str);
     if (*str == 0) {
index 0dc0d2b8ef715ca6c49ec0d4003e9f6979e26125..fa65ccb1f3fad76cdfa8655ac4a9b15dff39c50d 100644 (file)
@@ -1,6 +1,6 @@
 #include <SDL2/SDL.h>
 #include <SDL2/SDL_mixer.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdio.h>
 
 #include "game.h"
@@ -39,7 +39,7 @@ Game *create_game(const char *level_file_path,
                     size_t sound_sample_files_count,
                     SDL_Renderer *renderer)
 {
-    assert(level_file_path);
+    trace_assert(level_file_path);
 
     Lt *const lt = create_lt();
     if (lt == NULL) {
@@ -106,13 +106,13 @@ Game *create_game(const char *level_file_path,
 
 void destroy_game(Game *game)
 {
-    assert(game);
+    trace_assert(game);
     RETURN_LT0(game->lt);
 }
 
 int game_render(const Game *game)
 {
-    assert(game);
+    trace_assert(game);
 
     if (game->state == GAME_STATE_QUIT) {
         return 0;
@@ -138,8 +138,8 @@ int game_sound(Game *game)
 
 int game_update(Game *game, float delta_time)
 {
-    assert(game);
-    assert(delta_time > 0.0f);
+    trace_assert(game);
+    trace_assert(delta_time > 0.0f);
 
     if (game->state == GAME_STATE_QUIT) {
         return 0;
@@ -165,8 +165,8 @@ int game_update(Game *game, float delta_time)
 
 static int game_event_pause(Game *game, const SDL_Event *event)
 {
-    assert(game);
-    assert(event);
+    trace_assert(game);
+    trace_assert(event);
 
     switch (event->type) {
     case SDL_QUIT:
@@ -193,8 +193,8 @@ static int game_event_pause(Game *game, const SDL_Event *event)
 
 static int game_event_running(Game *game, const SDL_Event *event)
 {
-    assert(game);
-    assert(event);
+    trace_assert(game);
+    trace_assert(event);
 
     switch (event->type) {
     case SDL_QUIT:
@@ -284,8 +284,8 @@ static int game_event_console(Game *game, const SDL_Event *event)
 
 int game_event(Game *game, const SDL_Event *event)
 {
-    assert(game);
-    assert(event);
+    trace_assert(game);
+    trace_assert(event);
 
     switch (game->state) {
     case GAME_STATE_RUNNING:
@@ -308,8 +308,8 @@ int game_input(Game *game,
                const Uint8 *const keyboard_state,
                SDL_Joystick *the_stick_of_joy)
 {
-    assert(game);
-    assert(keyboard_state);
+    trace_assert(game);
+    trace_assert(keyboard_state);
 
     if (game->state == GAME_STATE_QUIT  ||
         game->state == GAME_STATE_PAUSE ||
index 03353bc8c3f6c7d882659fb7c70795e4c5b3bf05..c40de20866ac4ff727d719ce75e43d95d632da48 100644 (file)
@@ -1,5 +1,5 @@
 #include <SDL2/SDL.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <math.h>
 #include <stdbool.h>
 
@@ -51,7 +51,7 @@ Camera *create_camera(SDL_Renderer *renderer,
 
 void destroy_camera(Camera *camera)
 {
-    assert(camera);
+    trace_assert(camera);
 
     free(camera);
 }
@@ -60,7 +60,7 @@ int camera_fill_rect(Camera *camera,
                      Rect rect,
                      Color color)
 {
-    assert(camera);
+    trace_assert(camera);
 
     SDL_Rect view_port;
     SDL_RenderGetViewport(camera->renderer, &view_port);
@@ -94,7 +94,7 @@ int camera_draw_rect(Camera * camera,
                      Rect rect,
                      Color color)
 {
-    assert(camera);
+    trace_assert(camera);
 
     SDL_Rect view_port;
     SDL_RenderGetViewport(camera->renderer, &view_port);
@@ -121,7 +121,7 @@ int camera_draw_triangle(Camera *camera,
                          Triangle t,
                          Color color)
 {
-    assert(camera);
+    trace_assert(camera);
 
     SDL_Rect view_port;
     SDL_RenderGetViewport(camera->renderer, &view_port);
@@ -144,7 +144,7 @@ int camera_fill_triangle(Camera *camera,
                          Triangle t,
                          Color color)
 {
-    assert(camera);
+    trace_assert(camera);
 
     SDL_Rect view_port;
     SDL_RenderGetViewport(camera->renderer, &view_port);
@@ -200,8 +200,8 @@ int camera_render_debug_text(Camera *camera,
                              const char *text,
                              Vec position)
 {
-    assert(camera);
-    assert(text);
+    trace_assert(camera);
+    trace_assert(text);
 
     if (!camera->debug_mode) {
         return 0;
@@ -239,25 +239,25 @@ int camera_clear_background(Camera *camera,
 
 void camera_center_at(Camera *camera, Point position)
 {
-    assert(camera);
+    trace_assert(camera);
     camera->position = position;
 }
 
 void camera_toggle_debug_mode(Camera *camera)
 {
-    assert(camera);
+    trace_assert(camera);
     camera->debug_mode = !camera->debug_mode;
 }
 
 void camera_disable_debug_mode(Camera *camera)
 {
-    assert(camera);
+    trace_assert(camera);
     camera->debug_mode = 0;
 }
 
 void camera_toggle_blackwhite_mode(Camera *camera)
 {
-    assert(camera);
+    trace_assert(camera);
     camera->blackwhite_mode = !camera->blackwhite_mode;
 }
 
@@ -273,7 +273,7 @@ int camera_is_point_visible(const Camera *camera, Point p)
 
 Rect camera_view_port(const Camera *camera)
 {
-    assert(camera);
+    trace_assert(camera);
 
     SDL_Rect view_port;
     SDL_RenderGetViewport(camera->renderer, &view_port);
@@ -292,8 +292,8 @@ int camera_is_text_visible(const Camera *camera,
                            Vec position,
                            const char *text)
 {
-    assert(camera);
-    assert(text);
+    trace_assert(camera);
+    trace_assert(text);
 
     SDL_Rect view_port;
     SDL_RenderGetViewport(camera->renderer, &view_port);
@@ -369,7 +369,7 @@ int camera_render_debug_rect(Camera *camera,
                              Rect rect,
                              Color c)
 {
-    assert(camera);
+    trace_assert(camera);
 
     if (!camera->debug_mode) {
         return 0;
index 6fe480d1204e9831a08a8b382311cff24be9cc12..4ae7dc03a86ec388862a12cdde3cdcb17be591bb 100644 (file)
@@ -1,5 +1,5 @@
 #include <SDL2/SDL.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 
 #include "color.h"
 #include "game/camera.h"
@@ -38,7 +38,7 @@ struct Level
 
 Level *create_level_from_file(const char *file_name)
 {
-    assert(file_name);
+    trace_assert(file_name);
 
     Lt *const lt = create_lt();
     if (lt == NULL) {
@@ -152,13 +152,13 @@ Level *create_level_from_file(const char *file_name)
 
 void destroy_level(Level *level)
 {
-    assert(level);
+    trace_assert(level);
     RETURN_LT0(level->lt);
 }
 
 int level_render(const Level *level, Camera *camera)
 {
-    assert(level);
+    trace_assert(level);
 
     if (background_render(level->background, camera) < 0) {
         return -1;
@@ -201,8 +201,8 @@ int level_render(const Level *level, Camera *camera)
 
 int level_update(Level *level, float delta_time)
 {
-    assert(level);
-    assert(delta_time > 0);
+    trace_assert(level);
+    trace_assert(delta_time > 0);
 
     physical_world_apply_gravity(level->physical_world);
     boxes_float_in_lava(level->boxes, level->lava);
@@ -226,8 +226,8 @@ int level_update(Level *level, float delta_time)
 
 int level_event(Level *level, const SDL_Event *event)
 {
-    assert(level);
-    assert(event);
+    trace_assert(level);
+    trace_assert(event);
 
     switch (event->type) {
     case SDL_KEYDOWN:
@@ -252,8 +252,8 @@ int level_input(Level *level,
                 const Uint8 *const keyboard_state,
                 SDL_Joystick *the_stick_of_joy)
 {
-    assert(level);
-    assert(keyboard_state);
+    trace_assert(level);
+    trace_assert(keyboard_state);
     (void) the_stick_of_joy;
 
     if (keyboard_state[SDL_SCANCODE_A]) {
@@ -386,8 +386,8 @@ int level_enter_camera_event(Level *level, Camera *camera)
 Rigid_rect *level_rigid_rect(Level *level,
                              const char *rigid_rect_id)
 {
-    assert(level);
-    assert(rigid_rect_id);
+    trace_assert(level);
+    trace_assert(rigid_rect_id);
 
     Rigid_rect *rigid_rect = player_rigid_rect(level->player,
                                                rigid_rect_id);
@@ -415,8 +415,8 @@ void level_show_goal(Level *level, const char *goal_id)
 
 void level_hide_label(Level *level, const char *label_id)
 {
-    assert(level);
-    assert(label_id);
+    trace_assert(level);
+    trace_assert(label_id);
 
     labels_hide(level->labels, label_id);
 }
index 7954e0476759bca45946e2063cfa22a1e97cfa6d..eaecf20dc00e53be6e1313f910806f99e55a387c 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 
 #include "game/level/background.h"
 #include "math/rand.h"
@@ -61,7 +61,7 @@ Background *create_background_from_line_stream(LineStream *line_stream)
 
 void destroy_background(Background *background)
 {
-    assert(background);
+    trace_assert(background);
     RETURN_LT0(background->lt);
 }
 
@@ -69,8 +69,8 @@ void destroy_background(Background *background)
 int background_render(const Background *background,
                       Camera *camera)
 {
-    assert(background);
-    assert(camera);
+    trace_assert(background);
+    trace_assert(camera);
 
     if (camera_clear_background(
             camera,
@@ -116,8 +116,8 @@ int background_render(const Background *background,
 
 static void chunk_of_point(Point p, int *x, int *y)
 {
-    assert(x);
-    assert(y);
+    trace_assert(x);
+    trace_assert(y);
     *x = (int) (p.x / BACKGROUND_CHUNK_WIDTH);
     *y = (int) (p.y / BACKGROUND_CHUNK_HEIGHT);
 }
index 4788bd1f764b19a165501f0ed404784de4fa678e..40b57106a8ada45e89afc3bfa6b1ff52ad7b8d7e 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 
 #include "game/level/boxes.h"
 #include "game/level/physical_world.h"
@@ -18,7 +18,7 @@ struct Boxes
 
 Boxes *create_boxes_from_line_stream(LineStream *line_stream)
 {
-    assert(line_stream);
+    trace_assert(line_stream);
 
     Lt *lt = create_lt();
 
@@ -61,14 +61,14 @@ Boxes *create_boxes_from_line_stream(LineStream *line_stream)
 
 void destroy_boxes(Boxes *boxes)
 {
-    assert(boxes);
+    trace_assert(boxes);
     RETURN_LT0(boxes->lt);
 }
 
 int boxes_render(Boxes *boxes, Camera *camera)
 {
-    assert(boxes);
-    assert(camera);
+    trace_assert(boxes);
+    trace_assert(camera);
 
     for (size_t i = 0; i < boxes->count; ++i) {
         if (rigid_rect_render(boxes->bodies[i], camera) < 0) {
@@ -82,8 +82,8 @@ int boxes_render(Boxes *boxes, Camera *camera)
 int boxes_update(Boxes *boxes,
                  float delta_time)
 {
-    assert(boxes);
-    assert(delta_time);
+    trace_assert(boxes);
+    trace_assert(delta_time);
 
     for (size_t i = 0; i < boxes->count; ++i) {
         if (rigid_rect_update(boxes->bodies[i], delta_time) < 0) {
@@ -97,8 +97,8 @@ int boxes_update(Boxes *boxes,
 int boxes_add_to_physical_world(const Boxes *boxes,
                                 Physical_world *physical_world)
 {
-    assert(boxes);
-    assert(physical_world);
+    trace_assert(boxes);
+    trace_assert(physical_world);
 
     for (size_t i = 0; i < boxes->count; ++i) {
         if (physical_world_add_solid(
@@ -113,8 +113,8 @@ int boxes_add_to_physical_world(const Boxes *boxes,
 
 void boxes_float_in_lava(Boxes *boxes, Lava *lava)
 {
-    assert(boxes);
-    assert(lava);
+    trace_assert(boxes);
+    trace_assert(lava);
 
     for (size_t i = 0; i < boxes->count; ++i) {
         lava_float_rigid_rect(lava, boxes->bodies[i]);
@@ -123,8 +123,8 @@ void boxes_float_in_lava(Boxes *boxes, Lava *lava)
 
 Rigid_rect *boxes_rigid_rect(Boxes *boxes, const char *id)
 {
-    assert(boxes);
-    assert(id);
+    trace_assert(boxes);
+    trace_assert(id);
 
     for (size_t i = 0; i < boxes->count; ++i) {
         if (rigid_rect_has_id(boxes->bodies[i], id)) {
index 57b4d5ffc1274a798e5f34432b40efd854bf9acc..47c9f4b0d45bf31a402c9e7a5971a65a54c653a4 100644 (file)
@@ -1,5 +1,5 @@
 #include <SDL2/SDL.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <math.h>
 
 #include "goals.h"
@@ -36,7 +36,7 @@ struct Goals {
 
 Goals *create_goals_from_line_stream(LineStream *line_stream)
 {
-    assert(line_stream);
+    trace_assert(line_stream);
 
     Lt *const lt = create_lt();
     if (lt == NULL) {
@@ -116,7 +116,7 @@ Goals *create_goals_from_line_stream(LineStream *line_stream)
 
 void destroy_goals(Goals *goals)
 {
-    assert(goals);
+    trace_assert(goals);
     RETURN_LT0(goals->lt);
 }
 
@@ -124,8 +124,8 @@ static int goals_render_core(const Goals *goals,
                              size_t goal_index,
                              Camera *camera)
 {
-    assert(goals);
-    assert(camera);
+    trace_assert(goals);
+    trace_assert(camera);
 
     const Point position = vec_sum(
         goals->points[goal_index],
@@ -156,8 +156,8 @@ static int goals_render_core(const Goals *goals,
 int goals_render(const Goals *goals,
                  Camera *camera)
 {
-    assert(goals);
-    assert(camera);
+    trace_assert(goals);
+    trace_assert(camera);
 
     for (size_t i = 0; i < goals->count; ++i) {
         if (!goals_is_goal_hidden(goals, i)) {
@@ -173,8 +173,8 @@ int goals_render(const Goals *goals,
 void goals_update(Goals *goals,
                   float delta_time)
 {
-    assert(goals);
-    assert(delta_time > 0.0f);
+    trace_assert(goals);
+    trace_assert(delta_time > 0.0f);
     goals->angle = fmodf(goals->angle + 2.0f * delta_time, 2.0f * PI);
 }
 
@@ -228,8 +228,8 @@ void goals_cue(Goals *goals,
 void goals_checkpoint(const Goals *goals,
                       Player *player)
 {
-    assert(goals);
-    assert(player);
+    trace_assert(goals);
+    trace_assert(player);
 
     for (size_t i = 0; i < goals->count; ++i) {
         if (goals->cue_states[i] == CUE_STATE_HIT_NOTHING) {
@@ -240,8 +240,8 @@ void goals_checkpoint(const Goals *goals,
 
 void goals_hide(Goals *goals, const char *id)
 {
-    assert(goals);
-    assert(id);
+    trace_assert(goals);
+    trace_assert(id);
 
     for (size_t i = 0; i < goals->count; ++i) {
         if (strcmp(id, goals->ids[i]) == 0) {
@@ -253,8 +253,8 @@ void goals_hide(Goals *goals, const char *id)
 
 void goals_show(Goals *goals, const char *id)
 {
-    assert(goals);
-    assert(id);
+    trace_assert(goals);
+    trace_assert(id);
 
     for (size_t i = 0; i < goals->count; ++i) {
         if (strcmp(id, goals->ids[i]) == 0) {
index 1729dd358a4c27fcbc3f3ec19385f18d34d62afb..3bda942b6cb558fc58692d07296bc6bd1c119fb7 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdbool.h>
 
 #include "game/camera.h"
@@ -33,7 +33,7 @@ struct Labels
 
 Labels *create_labels_from_line_stream(LineStream *line_stream)
 {
-    assert(line_stream);
+    trace_assert(line_stream);
 
     Lt *const lt = create_lt();
     if (lt == NULL) {
@@ -136,15 +136,15 @@ Labels *create_labels_from_line_stream(LineStream *line_stream)
 
 void destroy_labels(Labels *label)
 {
-    assert(label);
+    trace_assert(label);
     RETURN_LT0(label->lt);
 }
 
 int labels_render(const Labels *label,
                  Camera *camera)
 {
-    assert(label);
-    assert(camera);
+    trace_assert(label);
+    trace_assert(camera);
 
     for (size_t i = 0; i < label->count; ++i) {
         /* Easing */
@@ -169,7 +169,7 @@ int labels_render(const Labels *label,
 void labels_update(Labels *label,
                    float delta_time)
 {
-    assert(label);
+    trace_assert(label);
     (void) delta_time;
 
     for (size_t i = 0; i < label->count; ++i) {
@@ -190,8 +190,8 @@ void labels_update(Labels *label,
 void labels_enter_camera_event(Labels *labels,
                                const Camera *camera)
 {
-    assert(labels);
-    assert(camera);
+    trace_assert(labels);
+    trace_assert(camera);
 
     for (size_t i = 0; i < labels->count; ++i) {
         const int became_visible = camera_is_text_visible(
@@ -211,8 +211,8 @@ void labels_enter_camera_event(Labels *labels,
 void labels_hide(Labels *labels,
                  const char *label_id)
 {
-    assert(labels);
-    assert(label_id);
+    trace_assert(labels);
+    trace_assert(label_id);
 
     for (size_t i = 0; i < labels->count; ++i) {
         if (strcmp(labels->ids[i], label_id) == 0 && labels->states[i] != LABEL_STATE_HIDDEN) {
index 0a1900f5b4c823eb331de4910bd3037514e16031..1e6456b7c7671d1b39e81d093de59def4ca4d318 100644 (file)
@@ -1,5 +1,5 @@
 #include <SDL2/SDL.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdio.h>
 
 #include "color.h"
@@ -22,7 +22,7 @@ struct Lava {
 
 Lava *create_lava_from_line_stream(LineStream *line_stream)
 {
-    assert(line_stream);
+    trace_assert(line_stream);
 
     Lt *lt = create_lt();
     if (lt == NULL) {
@@ -61,7 +61,7 @@ Lava *create_lava_from_line_stream(LineStream *line_stream)
 
 void destroy_lava(Lava *lava)
 {
-    assert(lava);
+    trace_assert(lava);
     RETURN_LT0(lava->lt);
 }
 
@@ -69,8 +69,8 @@ void destroy_lava(Lava *lava)
 int lava_render(const Lava *lava,
                 Camera *camera)
 {
-    assert(lava);
-    assert(camera);
+    trace_assert(lava);
+    trace_assert(camera);
 
     for (size_t i = 0; i < lava->rects_count; ++i) {
         if (wavy_rect_render(lava->rects[i], camera) < 0) {
@@ -83,7 +83,7 @@ int lava_render(const Lava *lava,
 
 int lava_update(Lava *lava, float delta_time)
 {
-    assert(lava);
+    trace_assert(lava);
 
     for (size_t i = 0; i < lava->rects_count; ++i) {
         if (wavy_rect_update(lava->rects[i], delta_time) < 0) {
@@ -97,7 +97,7 @@ int lava_update(Lava *lava, float delta_time)
 bool lava_overlaps_rect(const Lava *lava,
                         Rect rect)
 {
-    assert(lava);
+    trace_assert(lava);
 
     for (size_t i = 0; i < lava->rects_count; ++i) {
         if (rects_overlap(wavy_rect_hitbox(lava->rects[i]), rect)) {
@@ -110,7 +110,7 @@ bool lava_overlaps_rect(const Lava *lava,
 
 void lava_float_rigid_rect(Lava *lava, Rigid_rect *object)
 {
-    assert(lava);
+    trace_assert(lava);
 
     const Rect object_hitbox = rigid_rect_hitbox(object);
     for (size_t i = 0; i < lava->rects_count; ++i) {
index 978980293b8f2cf6c853ae855d41dddf436ea214..0e0cf66e1c10acd07fd8a37a80f7c491429ca243 100644 (file)
@@ -1,5 +1,5 @@
 #include <SDL2/SDL.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
@@ -44,7 +44,7 @@ Wavy_rect *create_wavy_rect(Rect rect, Color color)
 
 Wavy_rect *create_wavy_rect_from_line_stream(LineStream *line_stream)
 {
-    assert(line_stream);
+    trace_assert(line_stream);
     char color_name[7];
     Rect rect;
 
@@ -65,15 +65,15 @@ Wavy_rect *create_wavy_rect_from_line_stream(LineStream *line_stream)
 
 void destroy_wavy_rect(Wavy_rect *wavy_rect)
 {
-    assert(wavy_rect);
+    trace_assert(wavy_rect);
     RETURN_LT0(wavy_rect->lt);
 }
 
 int wavy_rect_render(const Wavy_rect *wavy_rect,
                      Camera *camera)
 {
-    assert(wavy_rect);
-    assert(camera);
+    trace_assert(wavy_rect);
+    trace_assert(camera);
 
     srand(42);
     for (float wave_scanner = 0;
@@ -100,7 +100,7 @@ int wavy_rect_render(const Wavy_rect *wavy_rect,
 int wavy_rect_update(Wavy_rect *wavy_rect,
                      float delta_time)
 {
-    assert(wavy_rect);
+    trace_assert(wavy_rect);
     wavy_rect->angle = fmodf(wavy_rect->angle + 2.0f * delta_time, 2 * PI);
 
     return 0;
index 0babba23002e381077c0f47a4cb2c5c7f37f6024..6b26a67d8ad270fb55d8f5f289f28a0391f60ff9 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdlib.h>
 
 #include "game/level/platforms.h"
@@ -48,7 +48,7 @@ Physical_world *create_physical_world(void)
 
 void destroy_physical_world(Physical_world *physical_world)
 {
-    assert(physical_world);
+    trace_assert(physical_world);
     RETURN_LT0(physical_world->lt);
 }
 
@@ -64,7 +64,7 @@ void physical_world_apply_gravity(Physical_world *physical_world)
 void physical_world_collide_solids(Physical_world *physical_world,
                                    Platforms *platforms)
 {
-    assert(physical_world);
+    trace_assert(physical_world);
 
     for (size_t i = 0; i < physical_world->size; ++i) {
         solid_collide_with_solid(
@@ -88,7 +88,7 @@ void physical_world_collide_solids(Physical_world *physical_world,
 int physical_world_add_solid(Physical_world *physical_world,
                              Solid_ref solid)
 {
-    assert(physical_world);
+    trace_assert(physical_world);
 
     if (physical_world->size >= physical_world->capacity) {
         const size_t new_capacity = physical_world->capacity * 2;
@@ -114,6 +114,6 @@ int physical_world_add_solid(Physical_world *physical_world,
 
 void physical_world_clean(Physical_world *physical_world)
 {
-    assert(physical_world);
+    trace_assert(physical_world);
     physical_world->size = 0;
 }
index 31dacc6f5ca6ccd55c50b9cb0d0d9992d0d12e19..3fd99661889a5cede28ef3b373f5112c4c05e977 100644 (file)
@@ -1,5 +1,5 @@
 #include <SDL2/SDL.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -22,7 +22,7 @@ struct Platforms {
 
 Platforms *create_platforms_from_line_stream(LineStream *line_stream)
 {
-    assert(line_stream);
+    trace_assert(line_stream);
 
     Lt *const lt = create_lt();
     if (lt == NULL) {
@@ -73,15 +73,15 @@ Platforms *create_platforms_from_line_stream(LineStream *line_stream)
 
 void destroy_platforms(Platforms *platforms)
 {
-    assert(platforms);
+    trace_assert(platforms);
     RETURN_LT0(platforms->lt);
 }
 
 int platforms_save_to_file(const Platforms *platforms,
                            const char *filename)
 {
-    assert(platforms);
-    assert(filename);
+    trace_assert(platforms);
+    trace_assert(filename);
 
     Lt *const lt = create_lt();
     if (lt == NULL) {
@@ -137,7 +137,7 @@ void platforms_touches_rect_sides(const Platforms *platforms,
                                   Rect object,
                                   int sides[RECT_SIDE_N])
 {
-    assert(platforms);
+    trace_assert(platforms);
 
     for (size_t i = 0; i < platforms->rects_size; ++i) {
         rect_object_impact(object, platforms->rects[i], sides);
index ecbc19dd5a28c095bc2f2bea0885bada137ccb48..27c6a490e1c94575d2a27e15893ac428eb08a51a 100644 (file)
@@ -1,5 +1,5 @@
 #include <SDL2/SDL.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -45,7 +45,7 @@ struct Player {
 
 Player *create_player_from_line_stream(LineStream *line_stream, Level *level)
 {
-    assert(line_stream);
+    trace_assert(line_stream);
 
     Lt *lt = create_lt();
 
@@ -128,8 +128,8 @@ Solid_ref player_as_solid(Player *player)
 int player_render(const Player * player,
                   Camera *camera)
 {
-    assert(player);
-    assert(camera);
+    trace_assert(player);
+    trace_assert(camera);
 
     switch (player->state) {
     case PLAYER_STATE_ALIVE:
@@ -147,7 +147,7 @@ int player_render(const Player * player,
 void player_update(Player *player,
                    float delta_time)
 {
-    assert(player);
+    trace_assert(player);
 
     switch (player->state) {
     case PLAYER_STATE_ALIVE: {
@@ -191,27 +191,27 @@ void player_collide_with_solid(Player *player, Solid_ref solid)
 
 void player_move_left(Player *player)
 {
-    assert(player);
+    trace_assert(player);
     rigid_rect_move(player->alive_body, vec(-PLAYER_SPEED, 0.0f));
 }
 
 void player_move_right(Player *player)
 {
-    assert(player);
+    trace_assert(player);
 
     rigid_rect_move(player->alive_body, vec(PLAYER_SPEED, 0.0f));
 }
 
 void player_stop(Player *player)
 {
-    assert(player);
+    trace_assert(player);
 
     rigid_rect_move(player->alive_body, vec(0.0f, 0.0f));
 }
 
 void player_jump(Player *player)
 {
-    assert(player);
+    trace_assert(player);
     if (player->jump_threshold < PLAYER_MAX_JUMP_THRESHOLD) {
         rigid_rect_transform_velocity(player->alive_body,
                                       make_mat3x3(1.0f, 0.0f, 0.0f,
@@ -229,7 +229,7 @@ void player_jump(Player *player)
 
 void player_die(Player *player)
 {
-    assert(player);
+    trace_assert(player);
 
     if (player->state == PLAYER_STATE_ALIVE) {
         const Rect hitbox =
@@ -244,8 +244,8 @@ void player_die(Player *player)
 void player_focus_camera(Player *player,
                          Camera *camera)
 {
-    assert(player);
-    assert(camera);
+    trace_assert(player);
+    trace_assert(camera);
 
     const Rect player_hitbox = rigid_rect_hitbox(player->alive_body);
 
@@ -259,8 +259,8 @@ void player_focus_camera(Player *player,
 void player_hide_goals(const Player *player,
                        Goals *goals)
 {
-    assert(player);
-    assert(goals);
+    trace_assert(player);
+    trace_assert(goals);
     goals_hide_from_player(goals, rigid_rect_hitbox(player->alive_body));
 }
 
@@ -309,8 +309,8 @@ void player_apply_force(Player *player, Vec force)
 
 Rigid_rect *player_rigid_rect(Player *player, const char *id)
 {
-    assert(player);
-    assert(id);
+    trace_assert(player);
+    trace_assert(id);
 
     if (player->state == PLAYER_STATE_ALIVE) {
         if (rigid_rect_has_id(player->alive_body, id)) {
@@ -324,7 +324,7 @@ Rigid_rect *player_rigid_rect(Player *player, const char *id)
 bool player_overlaps_rect(const Player *player,
                           Rect rect)
 {
-    assert(player);
+    trace_assert(player);
 
     return player->state == PLAYER_STATE_ALIVE
         && rects_overlap(
index f1f8692a0cff6fa33e95ab63f0a9103a397fce92..ba33ac4634f453eba5be405985b1fb35d560b189 100644 (file)
@@ -1,5 +1,5 @@
 #include <SDL2/SDL.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 
 #include "dying_rect.h"
 #include "math/rand.h"
@@ -57,15 +57,15 @@ Dying_rect *create_dying_rect(Color color,
 
 void destroy_dying_rect(Dying_rect *dying_rect)
 {
-    assert(dying_rect);
+    trace_assert(dying_rect);
     RETURN_LT0(dying_rect->lt);
 }
 
 int dying_rect_render(const Dying_rect *dying_rect,
                       Camera *camera)
 {
-    assert(dying_rect);
-    assert(camera);
+    trace_assert(dying_rect);
+    trace_assert(camera);
 
     for (size_t i = 0; i < DYING_RECT_PIECE_COUNT; ++i) {
         Color color = dying_rect->color;
@@ -90,8 +90,8 @@ int dying_rect_render(const Dying_rect *dying_rect,
 int dying_rect_update(Dying_rect *dying_rect,
                       float delta_time)
 {
-    assert(dying_rect);
-    assert(delta_time > 0.0f);
+    trace_assert(dying_rect);
+    trace_assert(delta_time > 0.0f);
 
     if (dying_rect_is_dead(dying_rect)) {
         return 0;
@@ -115,7 +115,7 @@ int dying_rect_update(Dying_rect *dying_rect,
 
 int dying_rect_is_dead(const Dying_rect *dying_rect)
 {
-    assert(dying_rect);
+    trace_assert(dying_rect);
     return dying_rect->time_passed >= dying_rect->duration;
 }
 
index bd39f390113fec290bf2f63688d74cfc1e7f7191..53907690feb576252575566425e66ed883ef89a0 100644 (file)
@@ -1,5 +1,5 @@
 #include <SDL2/SDL.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdio.h>
 #include <string.h>
 
@@ -54,7 +54,7 @@ static Vec opposing_force_by_sides(int sides[RECT_SIDE_N])
 
 Rigid_rect *create_rigid_rect(Rect rect, Color color, const char *id)
 {
-    assert(id);
+    trace_assert(id);
 
     Lt *lt = create_lt();
 
@@ -91,7 +91,7 @@ Rigid_rect *create_rigid_rect(Rect rect, Color color, const char *id)
 
 Rigid_rect *create_rigid_rect_from_line_stream(LineStream *line_stream)
 {
-    assert(line_stream);
+    trace_assert(line_stream);
 
     char color[7];
     Rect rect;
@@ -155,7 +155,7 @@ int rigid_rect_render(const Rigid_rect *rigid_rect,
 int rigid_rect_update(Rigid_rect * rigid_rect,
                       float delta_time)
 {
-    assert(rigid_rect);
+    trace_assert(rigid_rect);
 
     rigid_rect->touches_ground = 0;
 
@@ -181,8 +181,8 @@ int rigid_rect_update(Rigid_rect * rigid_rect,
 void rigid_rect_collide_with_solid(Rigid_rect * rigid_rect,
                                    Solid_ref solid)
 {
-    assert(rigid_rect);
-    assert(rigid_rect != solid.ptr);
+    trace_assert(rigid_rect);
+    trace_assert(rigid_rect != solid.ptr);
 
     int sides[RECT_SIDE_N] = { 0, 0, 0, 0 };
 
@@ -285,8 +285,8 @@ void rigid_rect_damper(Rigid_rect *rigid_rect, Vec v)
 bool rigid_rect_has_id(Rigid_rect *rigid_rect,
                        const char *id)
 {
-    assert(rigid_rect);
-    assert(id);
+    trace_assert(rigid_rect);
+    trace_assert(id);
 
     return strcmp(rigid_rect->id, id) == 0;
 }
index d9e8eee62c3fe75837cd99cb5d3d76e5396edeb4..6ece980691744e1db277e1961e16bc55a4d79181 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 
 #include "ebisp/gc.h"
 #include "ebisp/interpreter.h"
@@ -30,7 +30,7 @@ struct Regions
 
 Regions *create_regions_from_line_stream(LineStream *line_stream, Level *level)
 {
-    assert(line_stream);
+    trace_assert(line_stream);
 
     Lt *lt = create_lt();
     if (lt == NULL) {
@@ -133,14 +133,14 @@ Regions *create_regions_from_line_stream(LineStream *line_stream, Level *level)
 
 void destroy_regions(Regions *regions)
 {
-    assert(regions);
+    trace_assert(regions);
     RETURN_LT0(regions->lt);
 }
 
 void regions_player_enter(Regions *regions, Player *player)
 {
-    assert(regions);
-    assert(player);
+    trace_assert(regions);
+    trace_assert(player);
 
     for (size_t i = 0; i < regions->count; ++i) {
         if (regions->states[i] == RS_PLAYER_OUTSIDE &&
@@ -153,8 +153,8 @@ void regions_player_enter(Regions *regions, Player *player)
 
 void regions_player_leave(Regions *regions, Player *player)
 {
-    assert(regions);
-    assert(player);
+    trace_assert(regions);
+    trace_assert(player);
 
     for (size_t i = 0; i < regions->count; ++i) {
         if (regions->states[i] == RS_PLAYER_INSIDE &&
@@ -167,8 +167,8 @@ void regions_player_leave(Regions *regions, Player *player)
 
 int regions_render(Regions *regions, Camera *camera)
 {
-    assert(regions);
-    assert(camera);
+    trace_assert(regions);
+    trace_assert(camera);
 
     for (size_t i = 0; i < regions->count; ++i) {
         if (camera_render_debug_rect(
index 65ce3676f8d55cc0730b5f6ecd55fe6ba66affff..d0fe0c8f40a4cf224ae0fcc884d397a9c23f1259 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 
 #include "ebisp/gc.h"
 #include "ebisp/interpreter.h"
@@ -25,7 +25,7 @@ struct Script
 
 Script *create_script_from_line_stream(LineStream *line_stream, Level *level)
 {
-    assert(line_stream);
+    trace_assert(line_stream);
 
     Lt *lt = create_lt();
     if (lt == NULL) {
@@ -91,14 +91,14 @@ Script *create_script_from_line_stream(LineStream *line_stream, Level *level)
 
 void destroy_script(Script *script)
 {
-    assert(script);
+    trace_assert(script);
     RETURN_LT0(script->lt);
 }
 
 int script_eval(Script *script, const char *source_code)
 {
-    assert(script);
-    assert(source_code);
+    trace_assert(script);
+    trace_assert(source_code);
 
     struct ParseResult parse_result = read_expr_from_string(
         script->gc,
index c62281387bcfb27106b1a3a44f126463a374ed87..e1d9268ab8540391c01a3d8ab5f4fa5535a6d110 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 
 #include "ebisp/gc.h"
 #include "ebisp/interpreter.h"
@@ -11,9 +11,9 @@
 static struct EvalResult
 hide_goal(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
-    assert(param);
-    assert(gc);
-    assert(scope);
+    trace_assert(param);
+    trace_assert(gc);
+    trace_assert(scope);
 
     Level * const level = (Level*)param;
     char * goal_id = NULL;
@@ -31,9 +31,9 @@ hide_goal(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 static struct EvalResult
 show_goal(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
-    assert(param);
-    assert(gc);
-    assert(scope);
+    trace_assert(param);
+    trace_assert(gc);
+    trace_assert(scope);
 
     Level * const level = (Level*)param;
     const char *goal_id = NULL;
@@ -51,9 +51,9 @@ show_goal(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 static struct EvalResult
 rect_apply_force(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
-    assert(gc);
-    assert(scope);
-    assert(param);
+    trace_assert(gc);
+    trace_assert(scope);
+    trace_assert(param);
 
     Level *level = (Level*) param;
 
@@ -85,9 +85,9 @@ rect_apply_force(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 static struct EvalResult
 hide_label(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
-    assert(param);
-    assert(gc);
-    assert(scope);
+    trace_assert(param);
+    trace_assert(gc);
+    trace_assert(scope);
 
     Level *level = (Level*) param;
     const char *label_id = NULL;
index d1e9d7efe4968fd1ea8184835835bba455be5e96..b8d9126d24ffb2964c75880b439fc17d2bb16723 100644 (file)
@@ -1,6 +1,6 @@
 #include <SDL2/SDL.h>
 #include <SDL2/SDL_mixer.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -32,8 +32,8 @@ static int mix_get_free_channel(void)
 Sound_samples *create_sound_samples(const char *sample_files[],
                                       size_t sample_files_count)
 {
-    assert(sample_files);
-    assert(sample_files_count > 0);
+    trace_assert(sample_files);
+    trace_assert(sample_files_count > 0);
 
     Lt *lt = create_lt();
     if (lt == NULL) {
@@ -74,7 +74,7 @@ Sound_samples *create_sound_samples(const char *sample_files[],
 
 void destroy_sound_samples(Sound_samples *sound_samples)
 {
-    assert(sound_samples);
+    trace_assert(sound_samples);
     RETURN_LT0(sound_samples->lt);
 }
 
@@ -82,7 +82,7 @@ int sound_samples_play_sound(Sound_samples *sound_samples,
                             size_t sound_index,
                             int loops)
 {
-    assert(sound_samples);
+    trace_assert(sound_samples);
 
     if (sound_index < sound_samples->samples_count) {
         const int free_channel = mix_get_free_channel();
@@ -99,7 +99,7 @@ int sound_samples_play_sound(Sound_samples *sound_samples,
 
 int sound_samples_toggle_pause(Sound_samples *sound_samples)
 {
-    assert(sound_samples);
+    trace_assert(sound_samples);
 
     if (sound_samples->paused) {
         Mix_Resume(-1);
index 82c53ce485b20c01f3bfff7390977e9baad3ee7f..56c4aaff5757649d56fe4f8716d105fa6cf1f8ba 100644 (file)
@@ -1,5 +1,5 @@
 #include <SDL2/SDL.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdio.h>
 #include <string.h>
 
@@ -21,8 +21,8 @@ struct Sprite_font
 Sprite_font *create_sprite_font_from_file(const char *bmp_file_path,
                                             SDL_Renderer *renderer)
 {
-    assert(bmp_file_path);
-    assert(renderer);
+    trace_assert(bmp_file_path);
+    trace_assert(renderer);
 
     Lt * const lt = create_lt();
     if (lt == NULL) {
@@ -66,13 +66,13 @@ Sprite_font *create_sprite_font_from_file(const char *bmp_file_path,
 
 void destroy_sprite_font(Sprite_font *sprite_font)
 {
-    assert(sprite_font);
+    trace_assert(sprite_font);
     RETURN_LT0(sprite_font->lt);
 }
 
 static SDL_Rect sprite_font_char_rect(const Sprite_font *sprite_font, char x)
 {
-    assert(sprite_font);
+    trace_assert(sprite_font);
 
     if (32 <= x && x <= 126) {
         const SDL_Rect rect = {
@@ -94,9 +94,9 @@ int sprite_font_render_text(const Sprite_font *sprite_font,
                             Color color,
                             const char *text)
 {
-    assert(sprite_font);
-    assert(renderer);
-    assert(text);
+    trace_assert(sprite_font);
+    trace_assert(renderer);
+    trace_assert(text);
 
     const SDL_Color sdl_color = color_for_sdl(color);
 
@@ -132,8 +132,8 @@ Rect sprite_font_boundary_box(const Sprite_font *sprite_font,
                                 Vec size,
                                 const char *text)
 {
-    assert(sprite_font);
-    assert(text);
+    trace_assert(sprite_font);
+    trace_assert(text);
     return rect(
         position.x, position.y,
         size.x * FONT_CHAR_WIDTH * (float) strlen(text),
index 0139d09b0296f709d958d2e403ac670cb6be9c5c..b1959753cc06e4c5b11cdc05b4cf97b9e63a78f5 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <math.h>
 
 #include "point.h"
index a776afb1e729a56b57175136ecd9419a66271b8e..ba5fc9e8c192b974858eacc921fd96e23f3b5c6c 100644 (file)
@@ -1,5 +1,5 @@
 #include <SDL2/SDL.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <math.h>
 #include <string.h>
 
@@ -67,7 +67,7 @@ float line_length(Line line)
 
 void rect_object_impact(Rect object, Rect obstacle, int *sides)
 {
-    assert(sides);
+    trace_assert(sides);
 
     Rect int_area = rects_overlap_area(object, obstacle);
 
index b5cef1607814d1ec4ee853b56a32d18845b97c1c..b2e37cc4e8bfdf2b97fb315996ac940f0aa55cc5 100644 (file)
@@ -1,5 +1,5 @@
 #include <SDL2/SDL.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 
 #include "renderer.h"
 #include "system/lt.h"
@@ -8,7 +8,7 @@
 int draw_triangle(SDL_Renderer *render,
                   Triangle t)
 {
-    assert(render);
+    trace_assert(render);
 
     if (SDL_RenderDrawLine(render,
                            (int) roundf(t.p1.x),
@@ -43,7 +43,7 @@ int draw_triangle(SDL_Renderer *render,
 static int fill_bottom_flat_triangle(SDL_Renderer *render,
                                      Triangle t)
 {
-    assert(render);
+    trace_assert(render);
 
     const float invslope1 = (t.p2.x - t.p1.x) / (t.p2.y - t.p1.y);
     const float invslope2 = (t.p3.x - t.p1.x) / (t.p3.y - t.p1.y);
@@ -72,7 +72,7 @@ static int fill_bottom_flat_triangle(SDL_Renderer *render,
 static int fill_top_flat_triangle(SDL_Renderer *render,
                                   Triangle t)
 {
-    assert(render);
+    trace_assert(render);
 
     const float invslope1 = (t.p3.x - t.p1.x) / (t.p3.y - t.p1.y);
     const float invslope2 = (t.p3.x - t.p2.x) / (t.p3.y - t.p2.y);
index 447fe25049370c1f7b150296ee5795bf3146c536..3e4302f9383658ea1fabf906b0ae9cb738acca25 100644 (file)
--- a/src/str.c
+++ b/src/str.c
@@ -1,8 +1,8 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 
 #include "str.h"
 #include "system/nth_alloc.h"
@@ -43,7 +43,7 @@ char *trim_endline(char *s)
 
 char *string_append(char *prefix, const char *suffix)
 {
-    assert(suffix);
+    trace_assert(suffix);
 
     if (prefix == NULL) {
         return string_duplicate(suffix, NULL);
index 352c3c86ff9327759ed41016cd522f66afc523fb..9357032b5292411c2e92222ef282cce593269424 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -22,8 +22,8 @@ LineStream *create_line_stream(const char *filename,
                                const char *mode,
                                size_t capacity)
 {
-    assert(filename);
-    assert(mode);
+    trace_assert(filename);
+    trace_assert(mode);
 
     Lt *lt = create_lt();
     if (lt == NULL) {
@@ -63,14 +63,14 @@ LineStream *create_line_stream(const char *filename,
 
 void destroy_line_stream(LineStream *line_stream)
 {
-    assert(line_stream);
+    trace_assert(line_stream);
 
     RETURN_LT0(line_stream->lt);
 }
 
 const char *line_stream_next(LineStream *line_stream)
 {
-    assert(line_stream);
+    trace_assert(line_stream);
     return fgets(line_stream->buffer,
                  (int) line_stream->capacity,
                  line_stream->stream);
index 2021fd0bc80f2d479b51f6a2215a0c0aa8d1689a..1f4452032945d49ec6653aa6284e07e65df47caf 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 
 #include "ebisp/gc.h"
 #include "ebisp/scope.h"
@@ -9,8 +9,8 @@
 static struct EvalResult
 print(void *param, Gc *gc, struct Scope *scope, struct Expr args)
 {
-    assert(gc);
-    assert(scope);
+    trace_assert(gc);
+    trace_assert(scope);
     (void) param;
 
     const char *s = NULL;
index 3cc1e7afaf47e89df5835cf1e021934d5fce953a..30aeda51cc81078a915a9838362dd195478578dc 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -40,7 +40,7 @@ nth_alloc_lt_fail:
 
 void destroy_lt(Lt *lt)
 {
-    assert(lt);
+    trace_assert(lt);
 
     while (lt->size-- > 0) {
         if (lt->frames[lt->size]) {
@@ -54,9 +54,9 @@ void destroy_lt(Lt *lt)
 
 void *lt_push(Lt *lt, void *resource, Lt_destroy resource_destroy)
 {
-    assert(lt);
-    assert(resource_destroy);
-    assert(lt != resource);
+    trace_assert(lt);
+    trace_assert(resource_destroy);
+    trace_assert(lt != resource);
 
     if (resource == NULL) {
         return NULL;
@@ -78,10 +78,10 @@ void *lt_push(Lt *lt, void *resource, Lt_destroy resource_destroy)
 
 void* lt_reset(Lt *lt, void *old_resource, void *new_resource)
 {
-    assert(lt);
-    assert(old_resource);
-    assert(new_resource);
-    assert(old_resource != new_resource);
+    trace_assert(lt);
+    trace_assert(old_resource);
+    trace_assert(new_resource);
+    trace_assert(old_resource != new_resource);
 
     for (size_t i = 0; i < lt->size; ++i) {
         if (lt->frames[i] && lt_slot_contains_resource(lt->frames[i], old_resource)) {
@@ -95,8 +95,8 @@ void* lt_reset(Lt *lt, void *old_resource, void *new_resource)
 
 void *lt_release(Lt *lt, void *resource)
 {
-    assert(lt);
-    assert(resource);
+    trace_assert(lt);
+    trace_assert(resource);
 
     for (size_t i = 0; i < lt->size; ++i) {
         if (lt->frames[i] && lt_slot_contains_resource(lt->frames[i], resource)) {
@@ -111,9 +111,9 @@ void *lt_release(Lt *lt, void *resource)
 
 void *lt_replace(Lt *lt, void *old_resource, void *new_resource)
 {
-    assert(lt);
-    assert(old_resource);
-    assert(new_resource);
+    trace_assert(lt);
+    trace_assert(old_resource);
+    trace_assert(new_resource);
 
     for (size_t i = 0; i < lt->size; ++i) {
         if (lt->frames[i] && lt_slot_contains_resource(lt->frames[i], old_resource)) {
index d6e848747f005165e663a98d3ea473a72210a621..d38ec6f4770bced2483f947601b7fb11ebf5713c 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -13,8 +13,8 @@ struct Lt_slot
 
 Lt_slot *create_lt_slot(void *resource, Lt_destroy resource_destroy)
 {
-    assert(resource);
-    assert(resource_destroy);
+    trace_assert(resource);
+    trace_assert(resource_destroy);
 
     Lt_slot *lt_slot = nth_alloc(sizeof(Lt_slot));
     if (lt_slot == NULL) {
@@ -29,7 +29,7 @@ Lt_slot *create_lt_slot(void *resource, Lt_destroy resource_destroy)
 
 void *release_lt_slot(Lt_slot *lt_slot)
 {
-    assert(lt_slot);
+    trace_assert(lt_slot);
 
     void *resource = lt_slot->resource;
     free(lt_slot);
@@ -38,7 +38,7 @@ void *release_lt_slot(Lt_slot *lt_slot)
 
 void destroy_lt_slot(Lt_slot *lt_slot)
 {
-    assert(lt_slot);
+    trace_assert(lt_slot);
 
     lt_slot->resource_destroy(lt_slot->resource);
     free(lt_slot);
@@ -46,8 +46,8 @@ void destroy_lt_slot(Lt_slot *lt_slot)
 
 void lt_slot_reset_resource(Lt_slot *lt_slot, void *resource)
 {
-    assert(lt_slot);
-    assert(resource);
+    trace_assert(lt_slot);
+    trace_assert(resource);
 
     lt_slot->resource_destroy(lt_slot->resource);
     lt_slot->resource = resource;
@@ -55,16 +55,16 @@ void lt_slot_reset_resource(Lt_slot *lt_slot, void *resource)
 
 void lt_slot_replace_resource(Lt_slot *lt_slot, void *resource)
 {
-    assert(lt_slot);
-    assert(resource);
+    trace_assert(lt_slot);
+    trace_assert(resource);
 
     lt_slot->resource = resource;
 }
 
 int lt_slot_contains_resource(const Lt_slot *lt_slot, void *resource)
 {
-    assert(lt_slot);
-    assert(resource);
+    trace_assert(lt_slot);
+    trace_assert(resource);
 
     return lt_slot->resource == resource;
 }
index 52378aa51766397487e60c71afe9e9f783dc22e2..5c94bf34b2ba964489cf70f9029197ca79a04ace 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 
 #include "ebisp/gc.h"
 #include "ebisp/interpreter.h"
@@ -127,7 +127,7 @@ Console *create_console(Level *level,
 
 void destroy_console(Console *console)
 {
-    assert(console);
+    trace_assert(console);
     RETURN_LT0(console->lt);
 }
 
@@ -251,7 +251,7 @@ int console_render(const Console *console,
 
 int console_update(Console *console, float delta_time)
 {
-    assert(console);
+    trace_assert(console);
 
     if (console->a < 1.0f) {
         console->a += 1.0f / SLIDE_DOWN_TIME * delta_time;
@@ -266,6 +266,6 @@ int console_update(Console *console, float delta_time)
 
 void console_slide_down(Console *console)
 {
-    assert(console);
+    trace_assert(console);
     console->a = 0.0f;
 }
index 2a1ed4d77a94821c603fab5a79ef9f9d05b499c0..52556f454ed8d8e5b793f1af1b745ede555defbd 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdlib.h>
 #include <SDL2/SDL.h>
 
@@ -58,7 +58,7 @@ Console_Log *create_console_log(const Sprite_font *font,
 
 void destroy_console_log(Console_Log *console_log)
 {
-    assert(console_log);
+    trace_assert(console_log);
     for (size_t i = 0; i < console_log->capacity; ++i) {
         if (console_log->buffer[i]) {
             free(console_log->buffer[i]);
@@ -71,8 +71,8 @@ int console_log_render(const Console_Log *console_log,
                SDL_Renderer *renderer,
                Point position)
 {
-    assert(console_log);
-    assert(renderer);
+    trace_assert(console_log);
+    trace_assert(renderer);
     (void) position;
 
     for (size_t i = 0; i < console_log->capacity; ++i) {
@@ -95,8 +95,8 @@ int console_log_render(const Console_Log *console_log,
 
 int console_log_push_line(Console_Log *console_log, const char *line, Color color)
 {
-    assert(console_log);
-    assert(line);
+    trace_assert(console_log);
+    trace_assert(line);
 
     const size_t next_cursor = (console_log->cursor + 1) % console_log->capacity;
 
index b123d448155a9a769db208c5fc858efd89eb6ccb..f0968fbfe879a4dea6c438ea55e73626099160dd 100644 (file)
@@ -1,4 +1,4 @@
-#include <assert.h>
+#include "system/stacktrace.h"
 #include <stdbool.h>
 
 #include "edit_field.h"
@@ -30,7 +30,7 @@ Edit_field *create_edit_field(const Sprite_font *font,
                                 Vec font_size,
                                 Color font_color)
 {
-    assert(font);
+    trace_assert(font);
 
     Lt *lt = create_lt();
 
@@ -62,7 +62,7 @@ Edit_field *create_edit_field(const Sprite_font *font,
 
 void destroy_edit_field(Edit_field *edit_field)
 {
-    assert(edit_field);
+    trace_assert(edit_field);
     RETURN_LT0(edit_field->lt);
 }
 
@@ -70,8 +70,8 @@ int edit_field_render(const Edit_field *edit_field,
                       SDL_Renderer *renderer,
                       Point position)
 {
-    assert(edit_field);
-    assert(renderer);
+    trace_assert(edit_field);
+    trace_assert(renderer);
 
     const float cursor_y_overflow = 10.0f;
     const float cursor_width = 2.0f;
@@ -102,8 +102,8 @@ int edit_field_render(const Edit_field *edit_field,
 int edit_field_handle_event(Edit_field *edit_field,
                             const SDL_Event *event)
 {
-    assert(edit_field);
-    assert(event);
+    trace_assert(edit_field);
+    trace_assert(event);
 
     switch (event->type) {
     case SDL_KEYDOWN:
@@ -143,7 +143,7 @@ int edit_field_handle_event(Edit_field *edit_field,
 
 const char *edit_field_as_text(const Edit_field *edit_field)
 {
-    assert(edit_field);
+    trace_assert(edit_field);
     return edit_field->buffer;
 }
 
@@ -156,7 +156,7 @@ static void edit_field_left(Edit_field *edit_field)
 
 static void edit_field_right(Edit_field *edit_field)
 {
-    assert(edit_field);
+    trace_assert(edit_field);
     if (edit_field->cursor < edit_field->buffer_size) {
         edit_field->cursor++;
     }
@@ -164,7 +164,7 @@ static void edit_field_right(Edit_field *edit_field)
 
 static void edit_field_backspace(Edit_field *edit_field)
 {
-    assert(edit_field);
+    trace_assert(edit_field);
 
     if (edit_field->cursor == 0) {
         return;
@@ -180,7 +180,7 @@ static void edit_field_backspace(Edit_field *edit_field)
 
 static void edit_field_delete(Edit_field *edit_field)
 {
-    assert(edit_field);
+    trace_assert(edit_field);
 
     if (edit_field->cursor >= edit_field->buffer_size) {
         return;
@@ -195,7 +195,7 @@ static void edit_field_delete(Edit_field *edit_field)
 
 static void edit_field_insert_char(Edit_field *edit_field, char c)
 {
-    assert(edit_field);
+    trace_assert(edit_field);
 
     if (edit_field->buffer_size >= BUFFER_CAPACITY) {
         return;
@@ -211,7 +211,7 @@ static void edit_field_insert_char(Edit_field *edit_field, char c)
 
 void edit_field_clean(Edit_field *edit_field)
 {
-    assert(edit_field);
+    trace_assert(edit_field);
 
     edit_field->cursor = 0;
     edit_field->buffer_size = 0;
@@ -220,7 +220,7 @@ void edit_field_clean(Edit_field *edit_field)
 
 void edit_field_replace(Edit_field *edit_field, const char *text)
 {
-    assert(edit_field);
+    trace_assert(edit_field);
 
     edit_field_clean(edit_field);
 
index cddf5d394654c7efee29c5d1f248d1940df55d7c..9176bcff48293bbd8e0c08a8cebdacc007987001 100644 (file)
@@ -1,6 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 
 #include "history.h"
 #include "str.h"
@@ -47,7 +47,7 @@ History *create_history(size_t capacity)
 
 void destroy_history(History *history)
 {
-    assert(history);
+    trace_assert(history);
 
     for (size_t i = 0; i < history->capacity; ++i) {
         if (history->buffer[i] != NULL) {
@@ -60,8 +60,8 @@ void destroy_history(History *history)
 
 int history_push(History *history, const char *command)
 {
-    assert(history);
-    assert(command);
+    trace_assert(history);
+    trace_assert(command);
 
     const size_t next_begin = (history->begin + 1) % history->capacity;
 
@@ -83,13 +83,13 @@ int history_push(History *history, const char *command)
 
 const char *history_current(History *history)
 {
-    assert(history);
+    trace_assert(history);
     return history->buffer[history->cursor];
 }
 
 void history_prev(History *history)
 {
-    assert(history);
+    trace_assert(history);
     if (history->cursor == 0) {
         history->cursor = history->capacity - 1;
     } else {
@@ -99,6 +99,6 @@ void history_prev(History *history)
 
 void history_next(History *history)
 {
-    assert(history);
+    trace_assert(history);
     history->cursor = (history->cursor + 1) % history->capacity;
 }