27.11.2014 Views

CFFI User Manual - Common Lisp.net

CFFI User Manual - Common Lisp.net

CFFI User Manual - Common Lisp.net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6: Foreign Types 46<br />

foreign-slot-pointer<br />

Syntax<br />

foreign-slot-pointer ptr type slot-name ⇒ pointer<br />

Arguments and Values<br />

[Function]<br />

ptr<br />

type<br />

slot-names<br />

pointer<br />

A pointer to a structure.<br />

A foreign structure type.<br />

A slot name in the type.<br />

A pointer to the slot slot-name.<br />

Description<br />

Returns a pointer to the location of the slot slot-name in a foreign object of type type at<br />

ptr. The returned pointer points inside the structure. Both the pointer and the memory it<br />

points to have the same extent as ptr.<br />

For aggregate slots, this is the same value returned by foreign-slot-value.<br />

Examples<br />

(defcstruct point<br />

"Pointer structure."<br />

(x :int)<br />

(y :int))<br />

<strong>CFFI</strong>> (with-foreign-object (ptr ’(:struct point))<br />

(foreign-slot-pointer ptr ’(:struct point) ’x))<br />

⇒ #<br />

;; Note: the exact pointer representation varies from lisp to lisp.<br />

See Also<br />

[defcstruct], page 33<br />

[foreign-slot-value], page 47<br />

[foreign-slot-names], page 44<br />

[foreign-slot-offset], page 45

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!