-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstatus.go
102 lines (95 loc) · 5.41 KB
/
status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package cairo
// #include <cairo.h>
import "C"
import "fmt"
type Status int // cairo_status_t
const (
STATUS_SUCCESS Status = C.CAIRO_STATUS_SUCCESS
STATUS_NO_MEMORY Status = C.CAIRO_STATUS_NO_MEMORY
STATUS_INVALID_RESTORE Status = C.CAIRO_STATUS_INVALID_RESTORE
STATUS_INVALID_POP_GROUP Status = C.CAIRO_STATUS_INVALID_POP_GROUP
STATUS_NO_CURRENT_POINT Status = C.CAIRO_STATUS_NO_CURRENT_POINT
STATUS_INVALID_MATRIX Status = C.CAIRO_STATUS_INVALID_MATRIX
STATUS_INVALID_STATUS Status = C.CAIRO_STATUS_INVALID_STATUS
STATUS_NULL_POINTER Status = C.CAIRO_STATUS_NULL_POINTER
STATUS_INVALID_STRING Status = C.CAIRO_STATUS_INVALID_STRING
STATUS_INVALID_PATH_DATA Status = C.CAIRO_STATUS_INVALID_PATH_DATA
STATUS_READ_ERROR Status = C.CAIRO_STATUS_READ_ERROR
STATUS_WRITE_ERROR Status = C.CAIRO_STATUS_WRITE_ERROR
STATUS_SURFACE_FINISHED Status = C.CAIRO_STATUS_SURFACE_FINISHED
STATUS_SURFACE_TYPE_MISMATCH Status = C.CAIRO_STATUS_SURFACE_TYPE_MISMATCH
STATUS_PATTERN_TYPE_MISMATCH Status = C.CAIRO_STATUS_PATTERN_TYPE_MISMATCH
STATUS_INVALID_CONTENT Status = C.CAIRO_STATUS_INVALID_CONTENT
STATUS_INVALID_FORMAT Status = C.CAIRO_STATUS_INVALID_FORMAT
STATUS_INVALID_VISUAL Status = C.CAIRO_STATUS_INVALID_VISUAL
STATUS_FILE_NOT_FOUND Status = C.CAIRO_STATUS_FILE_NOT_FOUND
STATUS_INVALID_DASH Status = C.CAIRO_STATUS_INVALID_DASH
STATUS_INVALID_DSC_COMMENT Status = C.CAIRO_STATUS_INVALID_DSC_COMMENT
STATUS_INVALID_INDEX Status = C.CAIRO_STATUS_INVALID_INDEX
STATUS_CLIP_NOT_REPRESENTABLE Status = C.CAIRO_STATUS_CLIP_NOT_REPRESENTABLE
STATUS_TEMP_FILE_ERROR Status = C.CAIRO_STATUS_TEMP_FILE_ERROR
STATUS_INVALID_STRIDE Status = C.CAIRO_STATUS_INVALID_STRIDE
STATUS_FONT_TYPE_MISMATCH Status = C.CAIRO_STATUS_FONT_TYPE_MISMATCH
STATUS_USER_FONT_IMMUTABLE Status = C.CAIRO_STATUS_USER_FONT_IMMUTABLE
STATUS_USER_FONT_ERROR Status = C.CAIRO_STATUS_USER_FONT_ERROR
STATUS_NEGATIVE_COUNT Status = C.CAIRO_STATUS_NEGATIVE_COUNT
STATUS_INVALID_CLUSTERS Status = C.CAIRO_STATUS_INVALID_CLUSTERS
STATUS_INVALID_SLANT Status = C.CAIRO_STATUS_INVALID_SLANT
STATUS_INVALID_WEIGHT Status = C.CAIRO_STATUS_INVALID_WEIGHT
STATUS_INVALID_SIZE Status = C.CAIRO_STATUS_INVALID_SIZE
STATUS_USER_FONT_NOT_IMPLEMENTED Status = C.CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED
STATUS_DEVICE_TYPE_MISMATCH Status = C.CAIRO_STATUS_DEVICE_TYPE_MISMATCH
STATUS_DEVICE_ERROR Status = C.CAIRO_STATUS_DEVICE_ERROR
)
var statusNames = map[Status]string{
STATUS_SUCCESS: "CAIRO_STATUS_SUCCESS",
STATUS_NO_MEMORY: "CAIRO_STATUS_NO_MEMORY",
STATUS_INVALID_RESTORE: "CAIRO_STATUS_INVALID_RESTORE",
STATUS_INVALID_POP_GROUP: "CAIRO_STATUS_INVALID_POP_GROUP",
STATUS_NO_CURRENT_POINT: "CAIRO_STATUS_NO_CURRENT_POINT",
STATUS_INVALID_MATRIX: "CAIRO_STATUS_INVALID_MATRIX",
STATUS_INVALID_STATUS: "CAIRO_STATUS_INVALID_STATUS",
STATUS_NULL_POINTER: "CAIRO_STATUS_NULL_POINTER",
STATUS_INVALID_STRING: "CAIRO_STATUS_INVALID_STRING",
STATUS_INVALID_PATH_DATA: "CAIRO_STATUS_INVALID_PATH_DATA",
STATUS_READ_ERROR: "CAIRO_STATUS_READ_ERROR",
STATUS_WRITE_ERROR: "CAIRO_STATUS_WRITE_ERROR",
STATUS_SURFACE_FINISHED: "CAIRO_STATUS_SURFACE_FINISHED",
STATUS_SURFACE_TYPE_MISMATCH: "CAIRO_STATUS_SURFACE_TYPE_MISMATCH",
STATUS_PATTERN_TYPE_MISMATCH: "CAIRO_STATUS_PATTERN_TYPE_MISMATCH",
STATUS_INVALID_CONTENT: "CAIRO_STATUS_INVALID_CONTENT",
STATUS_INVALID_FORMAT: "CAIRO_STATUS_INVALID_FORMAT",
STATUS_INVALID_VISUAL: "CAIRO_STATUS_INVALID_VISUAL",
STATUS_FILE_NOT_FOUND: "CAIRO_STATUS_FILE_NOT_FOUND",
STATUS_INVALID_DASH: "CAIRO_STATUS_INVALID_DASH",
STATUS_INVALID_DSC_COMMENT: "CAIRO_STATUS_INVALID_DSC_COMMENT",
STATUS_INVALID_INDEX: "CAIRO_STATUS_INVALID_INDEX",
STATUS_CLIP_NOT_REPRESENTABLE: "CAIRO_STATUS_CLIP_NOT_REPRESENTABLE",
STATUS_TEMP_FILE_ERROR: "CAIRO_STATUS_TEMP_FILE_ERROR",
STATUS_INVALID_STRIDE: "CAIRO_STATUS_INVALID_STRIDE",
STATUS_FONT_TYPE_MISMATCH: "CAIRO_STATUS_FONT_TYPE_MISMATCH",
STATUS_USER_FONT_IMMUTABLE: "CAIRO_STATUS_USER_FONT_IMMUTABLE",
STATUS_USER_FONT_ERROR: "CAIRO_STATUS_USER_FONT_ERROR",
STATUS_NEGATIVE_COUNT: "CAIRO_STATUS_NEGATIVE_COUNT",
STATUS_INVALID_CLUSTERS: "CAIRO_STATUS_INVALID_CLUSTERS",
STATUS_INVALID_SLANT: "CAIRO_STATUS_INVALID_SLANT",
STATUS_INVALID_WEIGHT: "CAIRO_STATUS_INVALID_WEIGHT",
STATUS_INVALID_SIZE: "CAIRO_STATUS_INVALID_SIZE",
STATUS_USER_FONT_NOT_IMPLEMENTED: "CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED",
STATUS_DEVICE_TYPE_MISMATCH: "CAIRO_STATUS_DEVICE_TYPE_MISMATCH",
STATUS_DEVICE_ERROR: "CAIRO_STATUS_DEVICE_ERROR",
}
func (s Status) String() string {
name, ok := statusNames[s]
if ok {
return name
}
return fmt.Sprintf("%s(%d)", "Status", int(s))
}
func checkCairoStatus(nativeStatus C.cairo_status_t) error {
s := Status(nativeStatus)
if s == STATUS_SUCCESS {
return nil
}
return newCairoError(s.String())
}