bind-wrapper   macro


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/runtime/llvmti.xtm

Implementation

;; 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)))))


Back to Index