standalone: Add output_bool in demo library #331

Merged
sb10q merged 1 commits from enhance/add-output-bool-to-demo-lib into master 2024-08-17 17:37:20 +08:00
1 changed files with 10 additions and 9 deletions
Showing only changes of commit c5629d4eb5 - Show all commits

View File

@ -12,30 +12,31 @@
#error "Unsupported platform - Platform is not 32-bit or 64-bit" #error "Unsupported platform - Platform is not 32-bit or 64-bit"
#endif #endif
void output_bool(const bool x) { void output_bool(bool x) {
puts(x ? "True" : "False"); puts(x ? "True" : "False");
} }
void output_int32(const int32_t x) { void output_int32(int32_t x) {
printf("%d\n", x); printf("%d\n", x);
} }
void output_int64(const int64_t x) { void output_int64(int64_t x) {
printf("%ld\n", x); printf("%ld\n", x);
} }
void output_uint32(const uint32_t x) { void output_uint32(uint32_t x) {
printf("%d\n", x); printf("%d\n", x);
} }
void output_uint64(const uint64_t x) { void output_uint64(uint64_t x) {
printf("%ld\n", x); printf("%ld\n", x);
} }
void output_float64(const double x) { void output_float64(double x) {
printf("%f\n", x); printf("%f\n", x);
} }
void output_asciiart(const int32_t x) {
void output_asciiart(int32_t x) {
static const char *chars = " .,-:;i+hHM$*#@ "; static const char *chars = " .,-:;i+hHM$*#@ ";
if (x < 0) { if (x < 0) {
putchar('\n'); putchar('\n');
@ -45,12 +46,12 @@ void output_asciiart(const int32_t x) {
} }
struct cslice { struct cslice {
const void *data; void *data;
usize len; usize len;
}; };
void output_int32_list(struct cslice *slice) { void output_int32_list(struct cslice *slice) {
const int32_t *data = (const int32_t *) slice->data; const int32_t *data = (int32_t *) slice->data;
putchar('['); putchar('[');
for (usize i = 0; i < slice->len; ++i) { for (usize i = 0; i < slice->len; ++i) {