Created
December 22, 2016 15:35
-
-
Save LeifAndersen/57ff66754315d71c7f44d5c06712536c to your computer and use it in GitHub Desktop.
GST FFI binding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang racket/base | |
| (require ffi/unsafe | |
| ffi/unsafe/define | |
| racket/stxparam | |
| racket/splicing | |
| (for-syntax racket/base | |
| syntax/parse | |
| racket/syntax | |
| racket/string)) | |
| (provide (all-defined-out)) | |
| (define gstreamer-lib (ffi-lib "libgstreamer-1.0" '("0"))) | |
| (define-ffi-definer define-gst gstreamer-lib) | |
| (define-syntax-parameter current-func-name #f) | |
| (define-syntax (define-gst* stx) | |
| (syntax-parse stx | |
| [(_ name:id args ...) | |
| #:with c-name (format-id stx "~a" (string-replace (symbol->string (syntax-e #'name)) "-" "_")) | |
| (syntax/loc stx | |
| (splicing-syntax-parameterize ([current-func-name (make-rename-transformer #'name)]) | |
| (define-gst name args ... | |
| #:c-id c-name)))])) | |
| ;; Types | |
| (define _gquark _uint32) | |
| (define-cstruct _gerror | |
| ([domain _gquark] | |
| [code _int] | |
| [message _string])) | |
| (define-gst* gst-init (_fun [_int = (length vec)] [vec : (_list i _string)] -> _void)) | |
| (define-gst* gst-init-check (_fun [_int = (length vec)] [vec : (_list i _string)] _gerror-pointer | |
| -> [v : _bool] | |
| ));-> (ret-error v))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment