[Openmcl-devel] def-fore-type with :unsigned-doubleword
    Park SungMin 
    byulparan_eng at icloud.com
       
    Tue Dec  3 09:31:37 PST 2013
    
    
  
I working with CoreMIDI in ccl.(1.10-dev-r15972M-trunk  (DarwinX8664))
in CoreMIDI have type "structure MIDIPacket"
typedef UInt64 MIDITimeStamp;
struct MIDIPacket {
   MIDITimeStamp  timeStamp;
   UInt16         length;
   Byte           data[256];
};
so I wrapper it…
(ccl:def-foreign-type :midipacket
    (:struct :midipacket 
	     (time-stamp :unsigned-doubleword)
	     (length :unsigned-short)
	     (data (:array :unsigned-char 256))))
 in C… printf(“size: %d\n”, sizeof(struct MIDIPacket)) is 268,
but (/ (ccl::foreign-size :midipacket) 8) is 272.
This type used by this callback function for MidiEvent..
(ccl:defcallback midi-read-proc (:address packet-list
				 :address read-proc-ref-con
				 :address src-conn-ref-con
				 :void)
  (let ((pkt (ccl:pref packet-list :midi-packet-list.packet)))
    (format t "midipkt's length: ~a~%" (ccl:pref pkt :midi-packet.length))))
but it does not work correctly… It seems wrong read bytes……
so I changed it...
(ccl:def-foreign-type :midi-packet
  (:struct :midi-packet
	   (time-stamp :unsigned-int)
	   (time-stamp2 :unsigned-int)
	   (length :unsigned-short)
	   (data (:array :unsigned-char 256))))
then..(/ (ccl::foreign-size :midi-packet) 8) is 268, and callback is work correctly!
I was search google, so look it http://clozure.com/pipermail/openmcl-devel/2002-September/004407.html
This article is related to my problem?? or just bug??
sorry. my ugly English……but I wish you understand me…:-<
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20131204/98c4c137/attachment.htm>
    
    
More information about the Openmcl-devel
mailing list