Now that we have Alien types, operations and variables, we can manipulate foreign data structures. This C declaration can be translated into the following Alien type:
(def-alien-type nil (struct foo (a int) (b (array (* (struct foo)) 100))))
With this definition, the following C expression can be translated in this way:
(with-alien ((f (struct foo))) (slot (deref (slot f 'b) 7) 'a) ;; ;; Do something with f... )
Or consider this example of an external C variable and some accesses:
extern struct c_struct *my_struct;
my_struct->x++; my_struct->a = 5; my_struct = my_struct->n;
(def-alien-variable "my_struct" (* c-struct))
(incf (slot my-struct 'x)) (setf (slot my-struct 'a) 5) (setq my-struct (slot my-struct 'n))