func WrapDevice(p unsafe.Pointer) *Device {
	return wrapDevice((*C.cairo_device_t)(p))
}
Wrap a C cairo_device_t* found from some external source as a *Device.  The Go side will destroy the reference when it's no longer used.
package cairo
import (
	"fmt"
	"io"
	"runtime"
	"unsafe"
)
import "C"
func (s Status) Error() string {
	return C.GoString(C.cairo_status_to_string(C.cairo_status_t(s)))
}
func (surface *Surface) WriteToPNG(w io.Writer) error {
	data := writeClosure{w: w}
	key := goPointers.put(data)
	status := C.cairo_surface_write_to_png_stream((*C.cairo_surface_t)(surface.Ptr),
		(C.cairo_write_func_t)(unsafe.Pointer(C.gocairo_write_func)),
		unsafe.Pointer(&key))
	goPointers.clear(key)
	return Status(status).toError()
}
func ImageSurfaceCreateFromPNGStream(r io.Reader) (*ImageSurface, error) {
	data := readClosure{r: r}
	key := goPointers.put(data)
	surf := &ImageSurface{wrapSurface(C.cairo_image_surface_create_from_png_stream(
		(C.cairo_read_func_t)(unsafe.Pointer(C.gocairo_read_func)),
		unsafe.Pointer(&key)))}
	goPointers.clear(key)
	return surf, surf.status()
}
func (p *Path) Iter() *PathIter {
	return &PathIter{path: p, i: 0}
}
type PathIter struct {
	path *Path
	i    C.int
}
func (pi *PathIter) Next() *PathSegment {
	if pi.i >= pi.path.Ptr.num_data {
		return nil
	}
	dataArray := (*[1 << 30]C.cairo_path_data_t)(unsafe.Pointer(pi.path.Ptr.data))
	seg, ofs := decodePathSegment(unsafe.Pointer(&dataArray[pi.i]))
	pi.i += C.int(ofs)
	return seg
}
type ImageSurface struct {
	*Surface
}
type RecordingSurface struct {
	*Surface
}
type SurfaceObserver struct {
	*Surface
}
type ToyFontFace struct {
	*FontFace
}
type MeshPattern struct {
	*Pattern
}
type SVGSurface struct {
	*Surface
}
type XlibSurface struct {
	*Surface
}
type XlibDevice struct {
	*Device
}
func Version() int {
	ret := int(C.cairo_version())
	return ret
}
func VersionString() string {
	ret := C.GoString(C.cairo_version_string())
	return ret
}
type Context struct {
	Ptr *C.cairo_t
}
func freeContext(obj *Context) {
	C.cairo_destroy(obj.Ptr)
}
func wrapContext(p *C.cairo_t) *Context {
	ret := &Context{p}
	runtime.SetFinalizer(ret, freeContext)
	return ret
}
func WrapContext(p unsafe.Pointer) *Context {
	return wrapContext((*C.cairo_t)(p))
}
func BorrowContext(p unsafe.Pointer) *Context {
	return &Context{(*C.cairo_t)(p)}
}
type Surface struct {
	Ptr *C.cairo_surface_t
}
func freeSurface(obj *Surface) {
	C.cairo_surface_destroy(obj.Ptr)
}
func wrapSurface(p *C.cairo_surface_t) *Surface {
	ret := &Surface{p}
	runtime.SetFinalizer(ret, freeSurface)
	return ret
}
func WrapSurface(p unsafe.Pointer) *Surface {
	return wrapSurface((*C.cairo_surface_t)(p))
}
func BorrowSurface(p unsafe.Pointer) *Surface {
	return &Surface{(*C.cairo_surface_t)(p)}
}
type Device struct {
	Ptr *C.cairo_device_t
}
func freeDevice(obj *Device) {
	C.cairo_device_destroy(obj.Ptr)
}
func wrapDevice(p *C.cairo_device_t) *Device {
	ret := &Device{p}
	runtime.SetFinalizer(ret, freeDevice)
	return ret
}