Next: Strings, Previous: Foreign Types, Up: Top [Contents][Index]
All C data in CFFI is referenced through pointers. This includes defined C variables that hold immediate values, and integers.
To see why this is, consider the case of the C integer. It is not only an arbitrary representation for an integer, congruent to Lisp’s fixnums; the C integer has a specific bit pattern in memory defined by the C ABI. Lisp has no such constraint on its fixnums; therefore, it only makes sense to think of fixnums as C integers if you assume that CFFI converts them when necessary, such as when storing one for use in a C function call, or as the value of a C variable. This requires defining an area of memory11, represented through an effective address, and storing it there.
Due to this compartmentalization, it only makes sense to manipulate
raw C data in Lisp through pointers to it. For example, while there
may be a Lisp representation of a struct that is converted to C
at store time, you may only manipulate its raw data through a pointer.
The C compiler does this also, albeit informally.
| • Basic Pointer Operations: | ||
| • Allocating Foreign Memory: | ||
| • Accessing Foreign Memory: | ||
Dictionary | ||
|---|---|---|
| • foreign-free: | ||
| • foreign-alloc: | ||
| • foreign-symbol-pointer: | ||
| • inc-pointer: | ||
| • incf-pointer: | ||
| • make-pointer: | ||
| • mem-aptr: | ||
| • mem-aref: | ||
| • mem-ref: | ||
| • null-pointer: | ||
| • null-pointer-p: | ||
| • pointerp: | ||
| • pointer-address: | ||
| • pointer-eq: | ||
| • with-foreign-object: | ||
| • with-foreign-objects: | ||
| • with-foreign-pointer: | ||
Next: Strings, Previous: Foreign Types, Up: Top [Contents][Index]