Skip to content

Commit 6ced417

Browse files
committed
generate: Further progress on function and struct support
1 parent b8d925b commit 6ced417

File tree

4 files changed

+30
-40
lines changed

4 files changed

+30
-40
lines changed

macos/coregraphics/aliastypes.gen.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
"github.com/progrium/macdriver/macos/corefoundation"
99
"github.com/progrium/macdriver/macos/iosurface"
10-
"github.com/progrium/macdriver/objc"
1110
)
1211

1312
// A callback function that returns a generic pointer to the provider data. [Full Topic]
@@ -28,7 +27,7 @@ type ScreenRefreshCallback = func(count uint32, rects *Rect, userInfo unsafe.Poi
2827
// [Full Topic]
2928
//
3029
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgpdfdictionaryapplierblock?language=objc
31-
type PDFDictionaryApplierBlock = func(key *uint8, value unsafe.Pointer, info unsafe.Pointer) bool
30+
type PDFDictionaryApplierBlock = func(key string, value unsafe.Pointer, info unsafe.Pointer) bool
3231

3332
// Performs custom tasks at the beginning of a PostScript conversion process. [Full Topic]
3433
//
@@ -68,7 +67,7 @@ type PSConverterProgressCallback = func(info unsafe.Pointer)
6867
// A client-supplied callback function that’s invoked whenever an associated event tap receives a Quartz event. [Full Topic]
6968
//
7069
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgeventtapcallback?language=objc
71-
type EventTapCallBack = func(proxy unsafe.Pointer, type_ EventType, event EventRef, userInfo unsafe.Pointer) EventRef
70+
type EventTapCallBack = func(proxy EventTapProxy, type_ EventType, event EventRef, userInfo unsafe.Pointer) EventRef
7271

7372
// Copies data from a Core Graphics-supplied buffer into a data consumer. [Full Topic]
7473
//
@@ -83,7 +82,7 @@ type PathApplierFunction = func(info unsafe.Pointer, element *PathElement)
8382
// Performs custom processing on a key-value pair from a PDF dictionary, using optional contextual information. [Full Topic]
8483
//
8584
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgpdfdictionaryapplierfunction?language=objc
86-
type PDFDictionaryApplierFunction = func(key *uint8, value unsafe.Pointer, info unsafe.Pointer)
85+
type PDFDictionaryApplierFunction = func(key string, value unsafe.Pointer, info unsafe.Pointer)
8786

8887
// Release private data or resources associated with the pattern. [Full Topic]
8988
//
@@ -173,4 +172,4 @@ type DataProviderReleaseInfoCallback = func(info unsafe.Pointer)
173172
// A callback function that advances the current position in the data stream supplied by the provider. [Full Topic]
174173
//
175174
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgdataproviderskipforwardcallback?language=objc
176-
type DataProviderSkipForwardCallback = func(info unsafe.Pointer, count objc.Object) objc.Object
175+
type DataProviderSkipForwardCallback = func(info unsafe.Pointer, count int) int

macos/coregraphics/enumtypes.gen.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ type DirectDisplayID uint32
135135
// The percentage of blend color used in a fade operation. [Full Topic]
136136
//
137137
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgdisplayblendfraction?language=objc
138-
type DisplayBlendFraction float64
138+
type DisplayBlendFraction float32
139139

140140
// The configuration parameters that are passed to a display reconfiguration callback function. [Full Topic]
141141
//
@@ -164,7 +164,7 @@ type DisplayCount uint32
164164
// The duration in seconds of a fade operation or a fade hardware reservation. [Full Topic]
165165
//
166166
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgdisplayfadeinterval?language=objc
167-
type DisplayFadeInterval float64
167+
type DisplayFadeInterval float32
168168

169169
// A token issued by Quartz when reserving one or more displays for a fade operation during a specified interval. [Full Topic]
170170
//
@@ -174,7 +174,7 @@ type DisplayFadeReservationToken uint32
174174
// The time interval for a fade reservation. [Full Topic]
175175
//
176176
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgdisplayreservationinterval?language=objc
177-
type DisplayReservationInterval float64
177+
type DisplayReservationInterval float32
178178

179179
// Describes a frame update event. [Full Topic]
180180
//
@@ -451,7 +451,7 @@ const (
451451
// A value used to map a color generated in software to a color supported by the display hardware. [Full Topic]
452452
//
453453
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cggammavalue?language=objc
454-
type GammaValue float64
454+
type GammaValue float32
455455

456456
// [Full Topic]
457457
//
@@ -618,7 +618,7 @@ const (
618618
// A PDF Boolean value. [Full Topic]
619619
//
620620
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgpdfboolean?language=objc
621-
type PDFBoolean uint8
621+
type PDFBoolean byte
622622

623623
// Box types for a PDF page. [Full Topic]
624624
//

macos/coregraphics/functions.gen.go

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,25 @@ package coregraphics
66
// #import <stdint.h>
77
// #import <stdbool.h>
88
// #import "CoreGraphics/CoreGraphics.h"
9-
// void * ColorSpaceCreateCalibratedGray(float* whitePoint, float* blackPoint, float gamma);
10-
// bool PDFDocumentUnlockWithPassword(void * document, uint8_t* password);
9+
// bool PDFDictionaryGetArray(void * dict, char* key, void * value);
1110
import "C"
1211
import (
1312
"unsafe"
1413
)
1514

16-
// Creates a calibrated grayscale color space. [Full Topic]
15+
// Returns whether there is a PDF array associated with a specified key in a PDF dictionary and, if so, retrieves that array. [Full Topic]
1716
//
18-
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/1408887-cgcolorspacecreatecalibratedgray?language=objc
19-
func ColorSpaceCreateCalibratedGray(whitePoint *float64, blackPoint *float64, gamma float64) ColorSpaceRef {
20-
rv := C.ColorSpaceCreateCalibratedGray(
21-
// *typing.PointerType
22-
(*C.float)(unsafe.Pointer(whitePoint)),
23-
// *typing.PointerType
24-
(*C.float)(unsafe.Pointer(blackPoint)),
25-
// *typing.PrimitiveType
26-
C.float(gamma),
27-
)
28-
// *typing.RefType
29-
return ColorSpaceRef(rv)
30-
}
31-
32-
// Unlocks an encrypted PDF document when a valid password is supplied. [Full Topic]
33-
//
34-
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/1402599-cgpdfdocumentunlockwithpassword?language=objc
35-
func PDFDocumentUnlockWithPassword(document PDFDocumentRef, password *uint8) bool {
36-
rv := C.PDFDocumentUnlockWithPassword(
17+
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/1430229-cgpdfdictionarygetarray?language=objc
18+
func PDFDictionaryGetArray(dict unsafe.Pointer, key string, value unsafe.Pointer) bool {
19+
keyVal := C.CString(key)
20+
defer C.free(unsafe.Pointer(keyVal))
21+
rv := C.PDFDictionaryGetArray(
22+
// *typing.RefType
23+
unsafe.Pointer(dict),
24+
// *typing.CStringType
25+
keyVal,
3726
// *typing.RefType
38-
unsafe.Pointer(document),
39-
// *typing.PointerType
40-
(*C.uint8_t)(unsafe.Pointer(password)),
27+
unsafe.Pointer(value),
4128
)
4229
// *typing.PrimitiveType
4330
return bool(rv)

macos/coregraphics/functions.gen.m

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
// AUTO-GENERATED CODE, DO NOT MODIFY
22

33
#import "CoreGraphics/CoreGraphics.h"
4-
void * ColorSpaceCreateCalibratedGray(float* whitePoint, float* blackPoint, float gamma) {
5-
return (void *)CGColorSpaceCreateCalibratedGray(whitePoint, blackPoint, gamma);
6-
}
7-
BOOL PDFDocumentUnlockWithPassword(void * document, uint8_t* password) {
8-
return (BOOL)CGPDFDocumentUnlockWithPassword(document, password);
4+
bool PDFDictionaryGetArray(void * dict, char* key, void * value) {
5+
return (bool)CGPDFDictionaryGetArray(
6+
// *typing.RefType
7+
(CGPDFDictionaryRef*)dict,
8+
// *typing.CStringType
9+
(char*)key,
10+
// *typing.RefType
11+
(CGPDFArrayRef*)value
12+
);
913
}

0 commit comments

Comments
 (0)