alef 0.25.37

Opinionated polyglot binding generator for Rust libraries
Documentation
// Note: suppress incompatible-pointer-types warnings because cgo exports may have
// signatures that C strictly typechecks. The function pointers are ABI-compatible.
#pragma GCC diagnostic push
#if defined(__clang__)
#pragma GCC diagnostic ignored "-Wincompatible-function-pointer-types"
#else
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#endif
// C inline function to construct the {{ c_vtable_struct }} vtable.
// This allows direct assignment of function pointers with proper casting.
static inline {{ c_vtable_struct }}* {{ vtable_constructor }}(void) {
	// Note: All function pointers are assigned with generic casts to suppress warnings.
	// The actual function addresses are ABI-compatible despite signature differences.
	{{ c_vtable_struct }}* vtable = ({{ c_vtable_struct }}*)malloc(sizeof({{ c_vtable_struct }}));
	if (!vtable) return NULL;
	memset(vtable, 0, sizeof({{ c_vtable_struct }}));

{%- for field_name in method_field_names %}
	vtable->{{ field_name }} = (void(*)(void))go{{ trait_pascal }}{{ method_pascal_names[loop.index0] }};
{%- endfor %}
	vtable->free_string = (void(*)(void))go{{ trait_pascal }}FreeString;
	vtable->free_user_data = (void(*)(void))go{{ trait_pascal }}FreeUserData;
	vtable->name_fn = (void(*)(void))go{{ trait_pascal }}Name;
	vtable->version_fn = (void(*)(void))go{{ trait_pascal }}Version;
	vtable->initialize_fn = (void(*)(void))go{{ trait_pascal }}Initialize;
	vtable->shutdown_fn = (void(*)(void))go{{ trait_pascal }}Shutdown;

	return vtable;
}
#pragma GCC diagnostic pop