Skip to content

Commit

Permalink
Racket: Add yuniffi compat definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
okuoku committed Feb 11, 2015
1 parent 0d6f2bb commit 3386a6c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lib-compat/racket-yuni/compat/ffi/primitives.sls
@@ -0,0 +1,32 @@
(library (racket-yuni compat ffi primitives)
(export yuniffi-nccc-call
yuniffi-module-load
yuniffi-module-lookup)
(import (yuni scheme)
;; Some of definitions are placed in runtime
;; because we need to use keywords and other Racket specific
;; notations.
(yuni-runtime racket-ffi)
(ffi unsafe))

;;

(define (yuniffi-nccc-call func
in in-offset in-size
out out-offset out-size)
;; Bytevector is byte string in Racket. So we don't have to convert them.
(define inp (and in (ptr-add in (* in-offset 8))))
(define outp (and out (ptr-add out (* out-offset 8))))
(func inp in-size outp out-size))

(define (yuniffi-module-load path)
(ffi-lib path))


(define (yuniffi-module-lookup handle str)
;; nccc-func is defined in (yuni-runtime racket-ffi)
(get-ffi-obj str handle nccc-func
;; Failure thunk
(lambda () #f)))

)
9 changes: 9 additions & 0 deletions lib-runtime/racket/yuni-runtime/racket-ffi.mzscheme.sls
@@ -0,0 +1,9 @@
#!r6rs
(library (yuni-runtime racket-ffi)
(export nccc-func)
(import (rnrs)
(ffi unsafe))
(define nccc-func
(_fun _gcpointer _int _gcpointer _int -> _void))

)

0 comments on commit 3386a6c

Please sign in to comment.