tomo/stdlib/stdlib.h

49 lines
1.7 KiB
C
Raw Normal View History

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"
#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;
const TypeInfo_t *type;
2024-09-27 10:56:56 -07:00
void *dest;
} cli_arg_t;
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__})
__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();
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);
#define test(expr, typeinfo, expected, start, end) {\
start_test(__SOURCE_FILE__, start, end); \
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
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);
void print_stack_trace(FILE *out, int start, int stop);
2024-09-12 00:20:17 -07:00
void sleep_num(double seconds);
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