From: | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
Newsgroups: | comp.compilers |
Date: | Tue, 21 Jul 2009 11:29:48 GMT |
Organization: | Institut fuer Computersprachen, Technische Universitaet Wien |
References: | 09-07-074 |
Keywords: | code, design, bibliography |
Posted-Date: | 24 Jul 2009 18:25:20 EDT |
=?ISO-8859-1?Q?Christoffer_Lern=F6?= <lerno@dragonascendant.com> writes:
>I'd like to research FFI in various languages, basically to find the
>best FFI-solution and copy from that one.
>It's likely that I will restrict myself to interfacing with C, so if
>there are elegant solutions integrating with C, and more clunky but
>flexible that are more general, I probably prefer the ones that
>exclusively target C.
>
>What I'm looking for is syntax, to what extent automatic conversion of
>arguments are done, how to handle callbacks, memory management, how to
>create structured data (i.e. structs in the case of C) etc.
You may find the following paper interesting:
@InProceedings{ertl07euroforth,
author = "M. Anton Ertl",
title = "Gforth's libcc {C} Function Call Interface",
booktitle = "23rd EuroForth Conference",
year = "2007",
editor = "M. Anton Ertl",
pages = "7--11",
URL = "http://www.complang.tuwien.ac.at/papers/ertl07euroforth.ps.gz",
pdfurl = "http://www.complang.tuwien.ac.at/anton/euroforth2007/papers/ertl.pdf",
OPTnote = "not refereed",
abstract = "A major problem in our earlier proposal for a C
interface was that a part of the interface was not
portable between platforms. The libcc interface solves
this problem by using a C compiler and its
\code{.h}-files. The \code{.h}-files contain knowledge
about the specific platform, and the C compiler
automatically inserts the necessary conversions between
Forth and C types. In this paper we describe the libcc
implementation and interface. We also discuss how a
Forth-C interface might be standardized.",
}
Another thing you will want to look at is SWIG <www.swig.org>.
>[[...] all the FFI seems rather ad-hoc and language specific. -John]
There are lots of language-specific problems (e.g., the type systems
of the two languages involved, or the interaction of the garbage
collector with the C functions), so I think that it's necessary to be
language-specific, although SWIG tries to at least factor out the
language-independent parts.
- anton
--
M. Anton Ertl
anton@mips.complang.tuwien.ac.at
http://www.complang.tuwien.ac.at/anton/
Return to the
comp.compilers page.
Search the
comp.compilers archives again.