I have updated the example in tests/struct.lisp,<br><br>(defcfun "alloc_pair" (:pointer (:struct struct-pair))<br> (a :int)<br> (b :int))<br><br>and when I call alloc-pair, I get a pointer back:<br>(alloc-pair 1 2)<br>
#.(SB-SYS:INT-SAP #X00668E70)<br><br>I am not sure how you are seeing the problems you describe. Can you please send complete example(s) and describe what you see and what you expect? If you use the definitions already in the test system, that will make it a little bit easier. Thank you.<br>
<br><div class="gmail_quote">On Wed, Feb 8, 2012 at 2:28 PM, Ryan Pavlik <span dir="ltr"><<a href="mailto:reply%2Bi-1614209-ba246666762196459413560690eb7d3a39c7c7ee-838019@reply.github.com">reply+i-1614209-ba246666762196459413560690eb7d3a39c7c7ee-838019@reply.github.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I've been using this, and while it works great for by-value, there no longer seems to be a way to iterate struct arrays and get pointers back. This is bad, because I _don't_ always want a struct parsed. Parsing is slow and conses a lot.<br>
<br>
However, neither `(mem-aref ptr (:pointer (:struct foo)) n)` nor `(mem-aref ptr (:struct foo) n)` give the same thing as the function `(mem-aref ptr 'foo n)` does. Additionally, the compiler-macro form sets `*PARSE-BARE-STRUCTS-AS-POINTERS*`, so this results in incorrect iteration as well. I know at least a few existing codebases depend on the old behavior.<br>
<br>
For instance, I have a cstruct `POINT` which consists of two `:short`. The `foreign-type-size` is 4. However, with the compiler macro:<br>
<br>
```<br>
(with-foreign-object (ptr 'point 2)<br>
(mem-aref ptr 'point 1)) ;; -> ptr+8<br>
```<br>
<br>
This is identical to using `(mem-aref ptr '(:pointer (:struct point)) 1)`, and wrong. If the *function* gets called with the old parsing style, you get `ptr+4`, which is the only way to do so beyond using `mem-ref` and `foreign-type-size` manually. This breaks a lot of existing code.<br>
<br>
If I use `(mem-aref ptr '(:struct point) 1)`, I get values returned, not pointers, which is no good if I need the pointer itself.<br>
<br>
---<br>
<div class="im">Reply to this email directly or view it on GitHub:<br>
</div><a href="https://github.com/cffi/cffi/pull/2#issuecomment-3874222" target="_blank">https://github.com/cffi/cffi/pull/2#issuecomment-3874222</a><br>
</blockquote></div><br>