[MacRuby-devel] Pointer to memory. was: Pointers for BOOL types

Brian Chapados chapbr at gmail.com
Fri Jan 9 14:57:17 PST 2009


If it helps, for CGBitmapContextCreate you just pass NULL ('nil' in
MacRuby) for the void *data parameter and let CoreGraphics handle
allocating memory. Unless you really need to do the allocation
yourself, it is significantly less painful and less error-prone to
have it done automatically, especially if you're using CoreGraphics
from MacRuby.

Brian

On Fri, Jan 9, 2009 at 12:00 AM, John Shea <johnmacshea at gmail.com> wrote:
> Thanks for the pointer ( ;-))  Dave,
> I assume that there is some way to make it work since it seems, as you say,
> to be catered for, but with my code it either gives back garbage (ie not a
> pointer to the image i want) or falls into the debugger depending on whether
> i access it more than once.
> Never mind, I have a work-around that works fine -  it was easy to call out
> to an Objective C method where I could create the pointer in the C way (void
> *data = malloc(width * height * 4);).
> Cheers,
> John
>
>
> On Thu, Jan 8, 2009 at 6:45 PM, Dave Lee <davelee.com at gmail.com> wrote:
>>
>> try "^v". ^ is pointer, v is void.
>>
>> If you look at the .bridgesupport file, in this case
>>
>> /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Resources/BridgeSupport/CoreGraphicsFull.bridgesupport,
>> you'll see the the objc types listed for the various functions,
>> structs, etc.
>>
>> Dave
>>
>> On Sat, Jan 3, 2009 at 12:28 AM, John Shea <johnmacshea at gmail.com> wrote:
>> > So kind of on this topic ..
>> > which one of these ("c", "i", "s" etc) do I use for void pointers (to
>> > memory) eg. the data parameter in the method below? (when otherwise
>> > appropriately changed to ruby and Application.services imported etc).
>> >
>> > CGContextRef CGBitmapContextCreate (
>> >    void *data,
>> >    size_t width,
>> >    size_t height,
>> >    size_t bitsPerComponent,
>> >    size_t bytesPerRow,
>> >    CGColorSpaceRef colorspace,
>> >    CGBitmapInfo bitmapInfo
>> > );
>> >
>> > Cheers,
>> >
>> > J
>> >
>> > On Jan 2, 2009, at 11:21 PM, Dave Lee wrote:
>> >
>> > On Thu, Jan 1, 2009 at 7:37 PM, Lachie <lachiec at gmail.com> wrote:
>> >
>> > Cheque it:
>> >
>> > http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/chapter_7_section_1.html#//apple_ref/doc/uid/TP40008048-CH100-SW1
>> >
>> > see also: /usr/include/objc/runtime.h
>> >
>> > Dave
>> > _______________________________________________
>> > MacRuby-devel mailing list
>> > MacRuby-devel at lists.macosforge.org
>> > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>> >
>> >
>> > _______________________________________________
>> > MacRuby-devel mailing list
>> > MacRuby-devel at lists.macosforge.org
>> > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>> >
>> >
>> _______________________________________________
>> MacRuby-devel mailing list
>> MacRuby-devel at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
>


More information about the MacRuby-devel mailing list