Search code examples
macoscore-graphicscore-foundationjsctypes

CGRectMake Symbol not Found


I'm trying to declare some CoreGraphics functions, specificially CGRectMake and it keeps telling me symbol not found.

The docs say I need to import CoreGraphics: https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGGeometry/index.html#//apple_ref/c/func/CGRectMake

The path to my CoreGraphics is /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation; how can I find the right library for this function? I am doing this from ctypes.

By the way, from reading the docs it seems to just memset a CGRect and populate its width, height, x, and y is this true? (in which case I won't need to bother declaring it, it's so simple).


Solution

  • In the end I couldn't export the function so the solution I had to use was define the function myself, i guess that it was just returning a rect with fields populated and it worked :)

        CGRectMake: function() {
            /* https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGGeometry/index.html#//apple_ref/c/func/CGRectMake
             *  CGRect CGRectMake (
             *    CGFloat x,
             *    CGFloat y,
             *    CGFloat width,
             *    CGFloat height
             * ); 
             */
             /******* does not work
            return lib('CoreGraphics').declare('CGRectMake', self.TYPE.ABI,
                self.TYPE.CGRect,   // return
                self.TYPE.CGFloat,  // x
                self.TYPE.CGFloat,  // y
                self.TYPE.CGFloat,  // width
                self.TYPE.CGFloat   // height
            );
            */
            return function(x, y, width, height) {
                return self.TYPE.CGRect(
                    self.TYPE.CGPoint(x, y),
                    self.TYPE.CGSize(width, height)
                );
            };
        }