%module cairo
%{
#include <cairo-features.h> // must include this first
#include <cairo.h>
%}

%include <cairo-features.h> // must include this first
%include <cairo.h>

#if CAIRO_HAS_PDF_SURFACE
    %{
    #include <cairo-pdf.h>
    %}
    
    %include <cairo-pdf.h>
#endif

#if CAIRO_HAS_PS_SURFACE
    %{
    #include <cairo-ps.h>
    %}

    %include <cairo-ps.h>
#endif

#if CAIRO_HAS_QUARTZ_SURFACE
    %{
    #include <cairo-quartz.h>
    #include <cairo-quartz-image.h>
    %}

    // SWIG won't follow includes with includes (like Carbon/Carbon.h
    // from cairo-quartz.h), so these must be "shallowly" defined here.
    typedef struct CGContext *CGContextRef;
    typedef FMFont ATSUFontID;

    %include <cairo-quartz.h>
    %include <cairo-quartz-image.h>
#endif

#if CAIRO_HAS_SVG_SURFACE
    %{
    #include <cairo-svg.h>
    %}

    %include <cairo-svg.h>
#endif

#if CAIRO_HAS_WIN32_SURFACE
    %{
    #include <cairo-win32.h>
    %}

    // SWIG won't follow includes with includes (like windows.h),
    // so these must be "shallowly" defined here.
    typedef HANDLE HDC;
    typedef HANDLE HFONT;
    typedef struct LOGFONTW;

    %include <cairo-win32.h>
#endif

#if CAIRO_HAS_XCB_SURFACE
	%{
	#include <cairo-xcb.h>
	%}

    typedef struct xcb_connection_t xcb_connection_t;
    typedef uint32_t xcb_pixmap_t;
    typedef uint32_t xcb_drawable_t;
    typedef struct xcb_screen_t;

	%include <cairo-xcb.h>
#endif

#if CAIRO_HAS_XLIB_SURFACE
    %{
    #include <cairo-xlib.h>
    %}

    typedef struct _XDisplay Display;
    typedef struct Visual;
    typedef struct Screen;
    typedef XID Drawable;
    typedef XID Pixmap;

    %include <cairo-xlib.h>
#endif