Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make CoreGraphics compile

  • Loading branch information...
commit 6e9bc55c85c129ff648deb40ed24c2b98b92de78 1 parent d61d670
@reinerp authored
View
21 CoreFoundation/System/CoreFoundation.hs
@@ -13,6 +13,7 @@ module System.CoreFoundation(
module System.CoreFoundation.String,
module System.CoreFoundation.Time,
module System.CoreFoundation.URL,
+ -- $c2hsdecls
) where
import System.CoreFoundation.Base
@@ -29,3 +30,23 @@ import System.CoreFoundation.RunLoop
import System.CoreFoundation.String
import System.CoreFoundation.Time
import System.CoreFoundation.URL
+
+{- $c2hsdecls
+Clients of this library who use c2hs may find the following declarations useful:
+
+>{#pointer CFArrayRef as ArrayRef nocode#}
+>{#pointer CFMutableArrayRef as MArrayRef nocode #}
+>{#pointer CFTypeRef nocode#}
+>{#pointer CFBooleanRef as BooleanRef nocode#}
+>{#pointer CFBundleRef as BundleRef nocode#}
+>{#pointer CFDataRef as DataRef nocode#}
+>{#pointer CFDictionaryRef as DictionaryRef nocode#}
+>{#pointer CFErrorRef as ErrorRef nocode#}
+>{#pointer CFNotificationCenterRef as NotificationCenterRef nocode#}
+>{#pointer CFNumberRef as NumberRef nocode#}
+>{#pointer CFPropertyListRef as PlistRef nocode#}
+>{#pointer CFRunLoopRef as RunLoopRef nocode#}
+>{#pointer CFStringRef as StringRef nocode#}
+>{#pointer CFURLRef as URLRef nocode#}
+
+-}
View
4 CoreGraphics/CoreGraphics.cabal
@@ -27,8 +27,8 @@ flag 32bit
Library
Exposed-modules:
System.CoreGraphics
- System.CoreGraphics.AffineTransform
System.CoreGraphics.DataProvider
+ System.CoreGraphics.AffineTransform
System.CoreGraphics.Font
System.CoreGraphics.Context
System.CoreGraphics.Geometry
@@ -44,7 +44,7 @@ Library
CoreFoundation==0.1.*
Extensions: ForeignFunctionInterface, TemplateHaskell
- RecordWildCards, EmptyDataDecls
+ RecordWildCards, EmptyDataDecls, TypeFamilies
Build-tools: c2hs
View
3  CoreGraphics/System/CoreGraphics/Context.chs
@@ -19,12 +19,13 @@ import System.CoreFoundation.Foreign
import System.CoreFoundation.Internal.TH
import System.CoreGraphics.Geometry
-import System.CoreGraphics.Font
+{#import System.CoreGraphics.Font#}
import System.CoreGraphics.AffineTransform
#include "context.h"
declareCFTypeAs "CGContext" "Context"
+{#pointer CGContextRef as ContextRef nocode#}
with_ :: Storable a => a -> (Ptr () -> IO c) -> IO c
with_ x f = with x $ f . castPtr
View
24 CoreGraphics/System/CoreGraphics/DataProvider.chs
@@ -15,7 +15,27 @@ import System.CoreFoundation.Internal.TH
#include <ApplicationServices/ApplicationServices.h>
declareCFTypeAs "CGDataProvider" "DataProvider"
+{#pointer CGDataProviderRef as DataProviderRef nocode#}
-{#fun unsafe CGDataProviderCreateWithFilename as newDataProviderFromFile
+newDataProviderFromFile :: FilePath -> IO DataProvider
+newDataProviderFromFile file = getOwned $ cgNewDataProviderFromFile file
+
+{#fun unsafe CGDataProviderCreateWithFilename as cgNewDataProviderFromFile
{ withCString* `FilePath'
- } -> `DataProvider' getOwned* #}
+ } -> `DataProviderRef' id #}
+
+-- c2hs pointer hooks for CoreFoundation
+{#pointer CFArrayRef as ArrayRef nocode#}
+{#pointer CFMutableArrayRef as MArrayRef nocode #}
+{#pointer CFTypeRef nocode#}
+{#pointer CFBooleanRef as BooleanRef nocode#}
+{#pointer CFBundleRef as BundleRef nocode#}
+{#pointer CFDataRef as DataRef nocode#}
+{#pointer CFDictionaryRef as DictionaryRef nocode#}
+{#pointer CFErrorRef as ErrorRef nocode#}
+{#pointer CFNotificationCenterRef as NotificationCenterRef nocode#}
+{#pointer CFNumberRef as NumberRef nocode#}
+{#pointer CFPropertyListRef as PlistRef nocode#}
+{#pointer CFRunLoopRef as RunLoopRef nocode#}
+{#pointer CFStringRef as StringRef nocode#}
+{#pointer CFURLRef as URLRef nocode#}
View
10 CoreGraphics/System/CoreGraphics/Font.chs
@@ -16,16 +16,20 @@ import Foreign.Marshal.Array
import System.CoreFoundation.Base
import System.CoreFoundation.Foreign
import System.CoreFoundation.Internal.TH
-import System.CoreGraphics.DataProvider
+{#import System.CoreGraphics.DataProvider#}
#include <ApplicationServices/ApplicationServices.h>
#include "font.h"
declareCFTypeAs "CGFont" "Font"
+{#pointer CGFontRef as FontRef nocode#}
-{#fun unsafe CGFontCreateWithDataProvider as newFontWithDataProvider
+newFontWithDataProvider :: DataProvider -> IO Font
+newFontWithDataProvider dp = getOwned $ cgNewFontWithDataProvider dp
+
+{#fun unsafe CGFontCreateWithDataProvider as cgNewFontWithDataProvider
{ withObject* `DataProvider'
- } -> `Font' getOwned* #}
+ } -> `FontRef' id #}
type Glyph = {#type CGGlyph #}
View
17 CoreGraphics/System/CoreGraphics/PDF/Document.chs
@@ -12,18 +12,25 @@ import Foreign.C
import System.CoreFoundation.Base
import System.CoreFoundation.Foreign
import System.CoreFoundation.Internal.TH
-import System.CoreGraphics.DataProvider
+{#import System.CoreGraphics.DataProvider#}
import System.CoreFoundation.URL
#include <QuartzCore/QuartzCore.h>
declareCFTypeAs "CGPDFDocument" "PDFDocument"
+{#pointer CGPDFDocumentRef as PDFDocumentRef nocode#}
-{#fun CGPDFDocumentCreateWithProvider as newPDFDocumentWithProvider
- { withObject* `DataProvider' } -> `PDFDocument' getOwned* #}
+newPDFDocumentWithProvider :: DataProvider -> IO PDFDocument
+newPDFDocumentWithProvider dp = getOwned $ cgNewPDFDocumentWithProvider dp
-{#fun CGPDFDocumentCreateWithURL as newPDFDocumentWithURL
- { withObject* `URL' } -> `PDFDocument' getOwned* #}
+{#fun CGPDFDocumentCreateWithProvider as cgNewPDFDocumentWithProvider
+ { withObject* `DataProvider' } -> `PDFDocumentRef' id #}
+
+newPDFDocumentWithURL :: URL -> IO PDFDocument
+newPDFDocumentWithURL url = getOwned $ cgNewPDFDocumentWithURL url
+
+{#fun CGPDFDocumentCreateWithURL as cgNewPDFDocumentWithURL
+ { withObject* `URL' } -> `PDFDocumentRef' id #}
{#fun CGPDFDocumentGetNumberOfPages as getNumberOfPages
{ withObject* `PDFDocument' } -> `Int' #}
Please sign in to comment.
Something went wrong with that request. Please try again.