Permalink
Browse files

initial import

  • Loading branch information...
0 parents commit 73e41b715686dca356807af48f41a17f2e2664db @martindemello committed Jul 26, 2010
Showing with 83 additions and 0 deletions.
  1. +18 −0 Makefile
  2. +1 −0 README
  3. +2 −0 body.scm
  4. +14 −0 cprog-binding.scm
  5. +5 −0 cprog.c
  6. +8 −0 cprog.h
  7. +3 −0 direct-load.scm
  8. +16 −0 foo.import.scm
  9. +6 −0 outer.scm
  10. +10 −0 test.scm
@@ -0,0 +1,18 @@
+default: test
+
+test: outer cprog
+ csc -L. -lcprog test.scm
+
+outer:
+ csc -sJ outer.scm
+
+cprog:
+ gcc -c -fPIC -o cprog.o cprog.c
+ gcc -shared -o libcprog.so cprog.o
+
+direct-load:
+ csc -c direct-load.scm
+ csc -L. -lcprog direct-load.o
+
+clean:
+ rm *.so *.o test direct-load
@@ -0,0 +1 @@
+Playing around with Chicken Scheme's module system
@@ -0,0 +1,2 @@
+(define (hello)
+ (print "hello world"))
@@ -0,0 +1,14 @@
+(require-extension foreigners)
+
+#>
+#include "cprog.h"
+<#
+
+(define c:goodbye (foreign-lambda void "goodbye"))
+
+(define-foreign-enum-type (ccount int)
+ (ccount->int int->ccount)
+ (c:zero ZERO)
+ (c:one ONE)
+ (c:two TWO)
+ (c:three THREE))
@@ -0,0 +1,5 @@
+#include <stdio.h>
+
+void goodbye(void) {
+ printf("goodbye, cruel world\n");
+}
@@ -0,0 +1,8 @@
+enum {
+ ZERO,
+ ONE,
+ TWO,
+ THREE
+};
+
+void goodbye(void);
@@ -0,0 +1,3 @@
+(include "cprog-binding")
+
+(print c:one)
@@ -0,0 +1,16 @@
+;;;; foo.import.scm - GENERATED BY CHICKEN 4.5.0 -*- Scheme -*-
+
+(eval '(import chicken scheme foreign foreigners))
+(##sys#register-compiled-module
+ 'foo
+ (list)
+ '((hello . foo#hello)
+ (g58 . foo#g58)
+ (g57 . foo#g57)
+ (ccount->int . foo#ccount->int)
+ (int->ccount . foo#int->ccount)
+ (c:goodbye . foo#c:goodbye))
+ (list)
+ (list))
+
+;; END OF FILE
@@ -0,0 +1,6 @@
+(module foo *
+ (import chicken)
+ (import scheme)
+ (import foreign)
+ (include "cprog-binding")
+ (include "body"))
@@ -0,0 +1,10 @@
+(load "outer.so")
+(import foo)
+
+(hello)
+(c:goodbye)
+
+
+(print (int->ccount 1))
+(print (ccount->int 'c:one))
+(print c:one)

0 comments on commit 73e41b7

Please sign in to comment.