Org babel for complex embeddable common lisp interactions i.e. ansi common lisp as a C (or C++) library with duplexed embedding and interleaving.
|
|
||
|---|---|---|
| .gitignore | Initial commit | |
| c.ecl | ob-ecl working example in README. | |
| LICENSE | Initial commit | |
| Makefile | just copy ob-acl2 | |
| ob-ecl.el | ob-ecl working example in README. | |
| README.org | ob-ecl working example in README. | |
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