[MacRuby] #1080: Add #size method for C struct classes
#1080: Add #size method for C struct classes ---------------------------------+------------------------------------------ Reporter: kyossi212@… | Owner: lsansonetti@… Type: enhancement | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: C struct sizeof ---------------------------------+------------------------------------------ To use some sort of C-based API, It will helpful if MacRuby has capability of obtaining byte-size for C struct classes. NSRect.size in ruby code should be same as sizeof(NSRect) in c code. Use case example: AudioStreamGetPropertyInfo() in CoreAudio.framework returns required byte- size for it's outSize(4th argument). {{{ extern OSStatus AudioStreamGetPropertyInfo( AudioStreamID inStream, UInt32 inChannel, AudioDevicePropertyID inPropertyID, UInt32*outSize, /*total byte-size for required data in subsequence call*/ Boolean*outWritable); }}} for some inPropertyID enum value , outSize indicate total byte size for ( an array of some structure interested in). So, to get actual data (by subsequent call to AudioStreamGetProperty), we should calculate required array length, to allocate buffer. {{{ p=Pointer.new(StructFoo, outSize/StructFoo.size) }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1080> MacRuby <http://macruby.org/>
#1080: Add #size method for C struct classes ---------------------------------+------------------------------------------ Reporter: kyossi212@… | Owner: lsansonetti@… Type: enhancement | Status: closed Priority: major | Milestone: MacRuby 0.9 Component: MacRuby | Resolution: fixed Keywords: C struct sizeof | ---------------------------------+------------------------------------------ Changes (by lsansonetti@…): * status: new => closed * resolution: => fixed * milestone: => MacRuby 0.9 Comment: Should be added in r5117. All struct classes now respond to #size. -- Ticket URL: <http://www.macruby.org/trac/ticket/1080#comment:1> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby