[MacRuby-devel] How to set up and retrieve returned buffer from CTFrameGetLineOrigins?

Paul Howson paul-lists at tdgq.com.au
Thu May 6 19:59:03 PDT 2010


I need some help with this example which arises at the boundary between MacRuby and the C Core Text framework.

Consider the following Core Text function definition:

     void CTFrameGetLineOrigins( CTFrameRef frame, CFRange range, CGPoint origins[] )

The third argument is defined as:

"origins
The buffer to which the origins are copied. The buffer must have at least as many elements as specified by range's length."

Clearly origins is a buffer and a series of CGPoint structures are copied into it.

How can this be handled in MacRuby? Specifically:

1. What kind of argument should be passed? Presumably something constructed using the Pointer.new_with_type() function? Documentation on this function is very hard to find.

2. How to access the individual CGPoints in the returned buffer? This is not an Objective-C / MacRuby array object. It is just an address to a buffer. Easy to do in C, but how to do in MacRuby?

----------------------------------------------------------------
Paul Howson
Warwick Qld Australia


More information about the MacRuby-devel mailing list