You can use locations for your other vars as well -- in this case it
should work even for 64-bit values.
(let-location
((root unsigned-long)
(parent unsigned-long)
(children (c-pointer unsigned-long))
(nchildren unsigned-long))
(XQueryTree dpy win
(location root)
(location parent)
(location children)
(location nchildren))
...)
You still have, I think, the issue with the width of Window in the
children array. Perhaps you could write a little helper function
which indexes into an array of unsigned longs. I have done that below
building on my last message; I also defined a new foreign type
"Window" but you can just use unsigned-long directly if desired.
#>
typedef unsigned long Window;
Window buf[] = { 0xdeadbeefL, 0x12345678L };
void foo(Window **ret) {
*ret = buf;
}
<#
(define foo (foreign-lambda void "foo"
(c-pointer (c-pointer Window))))
(define-foreign-type Window unsigned-long)
(define window-array-ref
(foreign-lambda* Window (((c-pointer Window) array) (int n))
"return(array[n]);"))
(let-location ((ptr (c-pointer Window)))
(foo (location ptr))
(printf "~x ~x\n"
(window-array-ref ptr 0)
(window-array-ref ptr 1))) ; deadbeef 12345678
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users