1
1
Fork
You've already forked ickle
0
Org babel for complex embeddable common lisp interactions i.e. ansi common lisp as a C (or C++) library with duplexed embedding and interleaving.
  • Emacs Lisp 89.9%
  • ECL 6.6%
  • Makefile 3.5%
2026年07月14日 12:17:04 +12:00
.gitignore Initial commit 2026年07月08日 11:52:02 +02:00
c.ecl ob-ecl working example in README. 2026年07月14日 12:17:04 +12:00
LICENSE Initial commit 2026年07月08日 11:52:02 +02:00
Makefile just copy ob-acl2 2026年07月08日 23:35:05 +12:00
ob-ecl.el ob-ecl working example in README. 2026年07月14日 12:17:04 +12:00
README.org ob-ecl working example in README. 2026年07月14日 12:17:04 +12:00

ickle ; orgbabel infrastructure for ecl's sffi.

I guess you cloned https://codeberg.org/screwlisp/ickle.

Load the elisp package

 (load "~/gits/ickle/ob-ecl.el")
t

Test example of C source for ecl (sffi c-inline).

Admittedly the C does not look much like C. This is because the way ecl jiggles variables into and multiple C returns out of C/C++ is not a C feature. However, + at least really was C's +.

 @(return 0)=#0 - #1;
 @(return 1)=#0 + #1;

Now, tangling this resulted in the following useable but todo-filled /screwlisp/ickle/src/branch/main/c.ecl:

 (defun foo (a1 a2 &aux (ret nil))
 ;; convert and allocate e.g. cstrings in vars.
 (ffi:with-cstrings ()
 (unwind-protect
 (setq ret (multiple-value-list (ffi:c-inline (a1 a2 ) (:int :int ) (values :int :int)
 "@(return 0)=#0 - #1;
 @(return 1)=#0 + #1;"
 )))
 ;; deallocate / convert
 )
 )
 (apply #'values ret))

compile-file .. load using a conventional slime repl

This shows it works as such since ecl slime is happy with it.

 (compile-file "c.ecl" :load t)
#P"/home/screwlisp/gits/ickle/c.fas"
NIL
NIL
try it

Since org normally catches only the first return, turn the multiple (C!) returns into a list.

 (multiple-value-list (foo 1 2))
-1 3