garnet/rust/garnet_rs.h

64 lines
856 B
C
Raw Normal View History

#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
struct T {
2026-02-19 11:11:23 +00:00
bool a;
uint8_t b;
};
2026-02-19 11:11:23 +00:00
enum Shape_Tag {
Circle,
Rectangle,
};
2026-02-19 11:11:23 +00:00
struct Circle_Body {
2026-02-19 11:11:23 +00:00
double radius;
};
2026-02-19 11:11:23 +00:00
struct Rectangle_Body {
2026-02-19 11:11:23 +00:00
double width;
double height;
};
2026-02-19 11:11:23 +00:00
struct Shape {
enum Shape_Tag tag;
2026-02-19 11:11:23 +00:00
union {
struct Circle_Body circle;
struct Rectangle_Body rectangle;
2026-02-19 11:11:23 +00:00
} body;
};
2026-02-19 11:11:23 +00:00
2026-02-19 20:44:04 +00:00
enum BTree_Tag {
Leaf,
Fork,
};
struct Leaf_Body {
int64_t value;
};
struct Fork_Body {
const struct BTree *left;
const struct BTree *right;
};
struct BTree {
enum BTree_Tag tag;
union {
struct Leaf_Body leaf;
struct Fork_Body fork;
} body;
};
void hello(const char *c);
2026-02-19 11:11:23 +00:00
2026-02-19 11:15:38 +00:00
void hello_struct(struct T t);
2026-02-19 11:11:23 +00:00
2026-02-19 11:15:38 +00:00
void hello_shape(struct Shape s);
2026-02-19 15:26:27 +00:00
2026-02-19 15:56:55 +00:00
__attribute__((const)) int64_t add(int64_t a, int64_t b);
2026-02-19 20:44:04 +00:00
int64_t sum_tree(struct BTree t);