alef 0.25.37

Opinionated polyglot binding generator for Rust libraries
Documentation
package {{ pkg_name }}

/*
#cgo CFLAGS: -I${SRCDIR}/include -Wno-incompatible-function-pointer-types -Wno-incompatible-pointer-types
#include "{{ ffi_header }}"
#include <stdlib.h>
#include <string.h>

{% for spec in callbacks -%}
extern int32_t {{ spec.export_name }}({{ spec.c_sig }});
{% endfor -%}

static {{ callbacks_c_type }} makeVisitorCallbacks(void* userData) {
    {{ callbacks_c_type }} cb;
    memset(&cb, 0, sizeof(cb));
    cb.user_data = userData;
{% for spec in callbacks -%}
    cb.{{ spec.c_field }} = {{ spec.export_name }};
{% endfor -%}
    return cb;
}
*/
import "C"

import (
	"encoding/json"
	"fmt"
	"sync"
	"sync/atomic"
	"unsafe"
)