FFI: 'C structure' assignment/copying
John Pallister <[email protected]> Wed, 16 Apr 2003 21:52:00 +1200
| Newsgroups | gmane.lisp.corman |
|---|---|
| Message-ID | <5.2.0.9.0.20030416213154.00aaec58@goatboy> |
Is there a 'preferred' idiom for assigning (copying) instances of a C
structure defined with DEFCSTRUCT and allocated on the foreign heap?
That is, if I have e.g. a 4x4 matrix structure:
(ct:defcstruct matrix ((mat ((:single-float 4) 4))))
I can't say:
(defmacro deref-cpointer (ptr &optional (type '(:void *)))
`(ct:cref (,type *) ,ptr 0))
(let ((m1 (ct:malloc (ct:sizeof 'matrix)))
(m2 (ct:malloc (ct:sizeof 'matrix))))
(setf (deref-cpointer m1 matrix) (deref-cpointer m2 matrix)))
to be the equivalent of:
struct matrix { float mat[4][4]; } m1, m2; m1=m2;
I don't need member-wise assignment, just a straight memcpy. ;) So if
there's some nice little embedded assembler function somewhere in
sys/*.lisp that I could use, that would be great.
Cheers,
John :^P
--
John Pallister
[email protected]
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/xaxhjB/hdqFAA/VygGAA/SyjtlB/TM
---------------------------------------------------------------------~->
To unsubscribe from this group, send an email to:
[email protected]
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/