Something simular to you're pointer-pointer-ref is what I was using. and semantically it seems to be best.
Indy On Thu, Mar 12, 2009 at 6:25 PM, Eduardo Cavazos <[email protected]> wrote: > Eduardo Cavazos wrote: > >> XQueryTree is a function from xlib: >> >> extern Status XQueryTree( >> Display* /* display */, >> Window /* w */, >> Window* /* root_return */, >> Window* /* parent_return */, >> Window** /* children_return */, >> unsigned int* /* nchildren_return */ >> ); >> >> This is how I'm pulling it into Chicken (using a 'c-function' macro I'm >> using for cross-Scheme compatability): >> >> (c-function Status XQueryTree >> (Display* >> Window >> u32vector >> u32vector >> (c-pointer (c-pointer unsigned-long)) >> u32vector)) >> >> The tricky parameter is the 'Window**' one. >> >> I can allocate enough storage for a pointer via: >> >> (define children-return (allocate sizeof:c-pointer)) >> >> The trouble is, how do I portably extract the address? If I assume a >> 32-bit pointer size, it's easy: >> >> (pointer-u32-ref children-return) >> >> on a 64-bit machine, that should be: >> >> (pointer-u64-ref children-return) >> >> but, there is no 'pointer-u64-ref'. :-) >> >> Once I have the address, the rest is easy; convert it to a pointer with >> address->pointer, and extract individual windows with pointer-u32-ref. >> >> For reference, Ypsilon has this procedure that I use in this sort of case: >> >> bytevector-c-void*-ref >> >> Larceny has: >> >> %get-pointer > > Instead of pointer-u32-ref, or pointer-u64-ref, looks like I can have a > pointer-pointer-ref, which is similar to the Ypsilon and Larceny procedures > I mentioned: > > (define pointer-pointer-ref > (foreign-lambda* > c-pointer > ((c-pointer ptr)) > " C_return ( * ( ( void** ) ptr ) ) ; ")) > > I can proceed with that, but I'm still open to any suggestions! :-) > > Ed > > > _______________________________________________ > Chicken-users mailing list > [email protected] > http://lists.nongnu.org/mailman/listinfo/chicken-users > _______________________________________________ Chicken-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/chicken-users
