[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FFI Idea
From: |
Matt Birkholz |
Subject: |
Re: FFI Idea |
Date: |
Sun, 23 Feb 2020 12:14:32 -0700 |
User-agent: |
Evolution 3.34.1-2 |
On Sun, 2020-02-23 at 00:49 +0000, Scheming Pony wrote:
> In the case of embedded C++, with my method, I don't have to have a
> giant code-genned C shim library, and the wrapping Scheme functions
> become the specification of my library.
The "wrapping Scheme functions" like this?
(c-define '((in-C "static char *read_dir(DIR *p) \
{ \
struct dirent *dirp; \
dirp = readdir(p); \
if (!dirp) return(NULL); \
return(dirp->d_name); \
}")
(char* read_dir (DIR*)))
If you really like editing C code in Scheme mode and/or vice versa, it
would not be difficult to turn the above into e.g. a proj.c containing
static char *read_dir(DIR *p)
{
struct dirent *dirp;
dirp = readdir(p);
if (!dirp) return(NULL);
return(dirp->d_name);
}
for the C side and a proj.cdecl containing
(extern (* char) read_dir (p (* DIR)))
for the Scheme side, with maybe a proj-wrap.scm with more Scheme side
work (like consing a Scheme/Unicode string from the (* char)) depending
on your ultimate hopes for DWIM. I just personally don't see a whole
lot of difference... 1 file versus 3?
But you have your own value function and I don't mind helping you stick
a Do-What-Scheming-Pony-Means layer on top of my rude and ugly. ;-}
<praying the indented plain text source examples come through OK>
<cursing so-called modern user interfaces>