GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: A binding between erlang and mzscheme.
Clone URL: git://github.com/KirinDave/erlenmeyer.git
KirinDave (author)
Wed Feb 27 22:04:57 -0800 2008
commit  45878b3c8af8a50464c35cb232d873e2c70d5551
tree    d85d7f106c4b3b5d739bbba05660e9f09cde5923
parent  19dc20acd6722507cc5b48a636c3a554c6979dcc
erlenmeyer / src / erlenmeyer.scm
100644 29 lines (23 sloc) 0.994 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(module erlenmeyer mzscheme
  (require (lib "foreign.ss")) (unsafe!)
  (provide bind-erlang-ports
           fd->input-port
           fd->output-port)
 
; We'll start with the standard ports
  (define erlang-input-port (current-input-port))
  (define erlang-output-port (current-output-port))
 
 (define (bind-erlang-ports)
   (set! erlang-input-port (fd->input-port 3 'erlang-in))
   (set! erlang-output-port (fd->output-port 4 'erlang-out)))
  
; The all-important fd->input port code thanks to Matthew Flatt
  (define (fd->input-port fd name)
    (scheme_make_fd_input_port fd name 0 0))
 
  (define (fd->output-port fd name)
    (scheme_make_fd_output_port fd name 0 0 0))
 
  (define scheme_make_fd_input_port
    (get-ffi-obj "scheme_make_fd_input_port" #f
                 (_fun _int _scheme _int _int -> _scheme)))
 
  (define scheme_make_fd_output_port
    (get-ffi-obj "scheme_make_fd_output_port"
                  #f
                  (_fun _int _scheme _int _int _int -> _scheme))))