2024-02-04 18:13:50 -08:00
|
|
|
#pragma once
|
|
|
|
|
2024-03-18 09:57:49 -07:00
|
|
|
// Built-in functions
|
|
|
|
|
2024-02-04 18:13:50 -08:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
2024-09-13 11:25:03 -07:00
|
|
|
#include <stdio.h>
|
2024-02-04 18:13:50 -08:00
|
|
|
|
2024-08-11 11:47:34 -07:00
|
|
|
#include "datatypes.h"
|
2024-02-17 14:44:17 -08:00
|
|
|
#include "types.h"
|
2024-09-08 14:17:15 -07:00
|
|
|
#include "util.h"
|
2024-02-04 18:13:50 -08:00
|
|
|
|
2024-09-17 22:08:36 -07:00
|
|
|
extern bool USE_COLOR;
|
|
|
|
|
2024-09-27 10:56:56 -07:00
|
|
|
typedef struct {
|
|
|
|
const char *name;
|
|
|
|
bool required;
|
2024-09-30 11:39:30 -07:00
|
|
|
const TypeInfo_t *type;
|
2024-09-27 10:56:56 -07:00
|
|
|
void *dest;
|
|
|
|
} cli_arg_t;
|
|
|
|
|
2024-05-25 10:56:34 -07:00
|
|
|
void tomo_init(void);
|
2024-09-28 12:17:09 -07:00
|
|
|
void _tomo_parse_args(int argc, char *argv[], Text_t usage, Text_t help, int spec_len, cli_arg_t spec[spec_len]);
|
|
|
|
#define tomo_parse_args(argc, argv, usage, help, ...) \
|
|
|
|
_tomo_parse_args(argc, argv, usage, help, sizeof((cli_arg_t[]){__VA_ARGS__})/sizeof(cli_arg_t), (cli_arg_t[]){__VA_ARGS__})
|
2024-09-08 14:17:15 -07:00
|
|
|
__attribute__((format(printf, 1, 2)))
|
|
|
|
_Noreturn void fail(const char *fmt, ...);
|
|
|
|
__attribute__((format(printf, 4, 5)))
|
|
|
|
_Noreturn void fail_source(const char *filename, int64_t start, int64_t end, const char *fmt, ...);
|
2024-09-02 15:47:39 -07:00
|
|
|
Text_t builtin_last_err();
|
2024-05-13 21:30:57 -07:00
|
|
|
void start_test(const char *filename, int64_t start, int64_t end);
|
2024-10-30 22:30:12 -07:00
|
|
|
void end_test(const void *expr, const TypeInfo_t *type, const char *expected);
|
2024-09-04 02:01:21 -07:00
|
|
|
#define test(expr, typeinfo, expected, start, end) {\
|
2024-09-03 20:32:02 -07:00
|
|
|
start_test(__SOURCE_FILE__, start, end); \
|
2024-09-12 20:41:32 -07:00
|
|
|
auto _expr = expr; \
|
2024-10-30 22:30:12 -07:00
|
|
|
end_test(&_expr, typeinfo, expected); }
|
2024-09-02 15:47:39 -07:00
|
|
|
void say(Text_t text, bool newline);
|
2024-09-04 11:55:00 -07:00
|
|
|
Text_t ask(Text_t prompt, bool bold, bool force_tty);
|
2024-09-06 21:44:47 -07:00
|
|
|
_Noreturn void tomo_exit(Text_t text, int32_t status);
|
2024-02-04 18:13:50 -08:00
|
|
|
|
2024-09-11 10:56:39 -07:00
|
|
|
Closure_t spawn(Closure_t fn);
|
2024-09-02 15:47:39 -07:00
|
|
|
bool pop_flag(char **argv, int *i, const char *flag, Text_t *result);
|
2024-09-06 11:41:34 -07:00
|
|
|
void print_stack_trace(FILE *out, int start, int stop);
|
2024-09-12 00:20:17 -07:00
|
|
|
void sleep_num(double seconds);
|
2025-01-02 13:24:07 -08:00
|
|
|
public Closure_t _mutexed(const void *item, size_t size);
|
|
|
|
#define mutexed(item) _mutexed((__typeof(item)[1]){item}, sizeof(item))
|
2024-02-17 14:44:17 -08:00
|
|
|
|
2024-02-04 18:13:50 -08:00
|
|
|
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0
|