;; Wrap a native, bound C function, allowing it to be called from scheme
(define-macro (bind-wrapper local-sym native-sym)
(let* ((types (cdr (impc:ti:get-closure-arg-types (symbol->string native-sym))))
(args (map (lambda (t v) v)
types (make-list-with-proc
(length types)
(lambda (i)
(string->symbol (string-append "arg_" (atom->string i))))))))
`(bind-func ,local-sym
(lambda ,args
,(cons native-sym args)))))