[Openmcl-devel] Simple FFI Newb questions...
gb at clozure.com
Fri Aug 7 18:33:39 UTC 2009
The #_ reader macro expects to read a case-sensitive foreign function name,
(#_Py_Initialize [whatever args it takes if any])
At some point, #_ winds up interning a mixed-case symbol in the OS
package and defining that symbol as a macro that expands into some
sort of foreign-function call. Those symbols might show up in error
messages or backtraces, but you don't generally deal with them directly.
Foreign types (and field accessors) are represented as keywords with
upper-case substrings surrounded by angle brackets. The canonical
rectangle type used in Cocoa is called "NSRect" in ObjC, which is
represented as :<NSR>ect in CCL's FFI. That can get pretty difficult
to type (and to read); the #> reader macro reads a case-sensitive string
and returns a keyword with angle brackets in the right places:
which is at least slightly better than having to type the angle brackets
If you mix the two (#_ and #>), you get the behavior that you got: the
FFI can't find a foreign function named by a keyword that contains angle
brackets in its name. (I suppose that we -could- try to interpret that
as a foreign function name and install a macro on the keyword, but we don't.)
On Fri, 7 Aug 2009, Michael Kohout wrote:
> Hi all-
> Inspired by a previous post, I'm trying to import python2.5 using ccl's ffi,
> but I'm having troubles.
> I've built and run ffigen, written my populate.sh script, called it from
> within ccl with (ccl:create-interfaces :python25), and referenced those
> interfaces with (use-interface-dir :python25).
> After which I try to call a function defined by python's c api: (#_
> However, when I try to call a function defined in python's c lib, I get an
> Foreign function not found: :<P>Y_<I>NITIALIZE
> Any suggestions? Am I missing any steps?
> Mike Kohout
More information about the Openmcl-devel