#include "libsuicmez/libsuicmez.h" #include #include #include #include void* gc_alloc(const TypeInfo* type, size_t size); void gc_init(void); void gc_shutdown(void); // Helper for allocating arrays static void* suic_alloc_array(const TypeInfo* type, size_t elem_size, size_t len, void* init_data) { void* ptr = gc_alloc(type, elem_size * len); if (init_data) memcpy(ptr, init_data, elem_size * len); return ptr; } // Helper for allocating structs static void* suic_alloc_struct(const TypeInfo* type, size_t size, void* init_data) { void* ptr = gc_alloc(type, size); if (init_data) memcpy(ptr, init_data, size); return ptr; } struct Point { int x; int y; }; struct Person { char* name; int age; }; static const uint8_t sui_bitmap_Point[] = { 0, 0 }; static const TypeInfo sui_typeinfo_Point = { .field_count = 2, .pointer_count = 0, .pointer_bitmap = sui_bitmap_Point }; static const uint8_t sui_bitmap_Person[] = { 1, 0 }; static const TypeInfo sui_typeinfo_Person = { .field_count = 2, .pointer_count = 1, .pointer_bitmap = sui_bitmap_Person }; int suic_main(void); int suic_main(void) { struct Point* p = suic_alloc_struct(&sui_typeinfo_Point, sizeof(struct Point), &(struct Point){ .x = 5, .y = 10 }); struct Person* person = suic_alloc_struct(&sui_typeinfo_Person, sizeof(struct Person), &(struct Person){ .name = suic_alloc_array(NULL, sizeof(char), 6, "Alice"), .age = 30 }); int _ = ((*p).x + (*person).age); return 0; } int main(int argc, char* argv[]) { // Initialize GC gc_init(); // init globals // init event loop int result = suic_main(); // Shutdown GC gc_shutdown(); return result; }