Skip to content

Commit

Permalink
generate: Further progress on function and struct support
Browse files Browse the repository at this point in the history
  • Loading branch information
tmc committed Sep 3, 2023
1 parent b8d925b commit 6ced417
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 40 deletions.
9 changes: 4 additions & 5 deletions macos/coregraphics/aliastypes.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/progrium/macdriver/macos/corefoundation"
"github.com/progrium/macdriver/macos/iosurface"
"github.com/progrium/macdriver/objc"
)

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

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

Check failure on line 70 in macos/coregraphics/aliastypes.gen.go

View workflow job for this annotation

GitHub Actions / test (oldstable, macos-11)

undefined: EventTapProxy

Check failure on line 70 in macos/coregraphics/aliastypes.gen.go

View workflow job for this annotation

GitHub Actions / test (oldstable, macos-12)

undefined: EventTapProxy

Check failure on line 70 in macos/coregraphics/aliastypes.gen.go

View workflow job for this annotation

GitHub Actions / test (oldstable, macos-13)

undefined: EventTapProxy

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

// Release private data or resources associated with the pattern. [Full Topic]
//
Expand Down Expand Up @@ -173,4 +172,4 @@ type DataProviderReleaseInfoCallback = func(info unsafe.Pointer)
// A callback function that advances the current position in the data stream supplied by the provider. [Full Topic]
//
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgdataproviderskipforwardcallback?language=objc
type DataProviderSkipForwardCallback = func(info unsafe.Pointer, count objc.Object) objc.Object
type DataProviderSkipForwardCallback = func(info unsafe.Pointer, count int) int
10 changes: 5 additions & 5 deletions macos/coregraphics/enumtypes.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ type DirectDisplayID uint32
// The percentage of blend color used in a fade operation. [Full Topic]
//
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgdisplayblendfraction?language=objc
type DisplayBlendFraction float64
type DisplayBlendFraction float32

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

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

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

// [Full Topic]
//
Expand Down Expand Up @@ -618,7 +618,7 @@ const (
// A PDF Boolean value. [Full Topic]
//
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgpdfboolean?language=objc
type PDFBoolean uint8
type PDFBoolean byte

// Box types for a PDF page. [Full Topic]
//
Expand Down
37 changes: 12 additions & 25 deletions macos/coregraphics/functions.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,25 @@ package coregraphics
// #import <stdint.h>
// #import <stdbool.h>
// #import "CoreGraphics/CoreGraphics.h"
// void * ColorSpaceCreateCalibratedGray(float* whitePoint, float* blackPoint, float gamma);
// bool PDFDocumentUnlockWithPassword(void * document, uint8_t* password);
// bool PDFDictionaryGetArray(void * dict, char* key, void * value);
import "C"
import (
"unsafe"
)

// Creates a calibrated grayscale color space. [Full Topic]
// Returns whether there is a PDF array associated with a specified key in a PDF dictionary and, if so, retrieves that array. [Full Topic]
//
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/1408887-cgcolorspacecreatecalibratedgray?language=objc
func ColorSpaceCreateCalibratedGray(whitePoint *float64, blackPoint *float64, gamma float64) ColorSpaceRef {
rv := C.ColorSpaceCreateCalibratedGray(
// *typing.PointerType
(*C.float)(unsafe.Pointer(whitePoint)),
// *typing.PointerType
(*C.float)(unsafe.Pointer(blackPoint)),
// *typing.PrimitiveType
C.float(gamma),
)
// *typing.RefType
return ColorSpaceRef(rv)
}

// Unlocks an encrypted PDF document when a valid password is supplied. [Full Topic]
//
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/1402599-cgpdfdocumentunlockwithpassword?language=objc
func PDFDocumentUnlockWithPassword(document PDFDocumentRef, password *uint8) bool {
rv := C.PDFDocumentUnlockWithPassword(
// [Full Topic]: https://developer.apple.com/documentation/coregraphics/1430229-cgpdfdictionarygetarray?language=objc
func PDFDictionaryGetArray(dict unsafe.Pointer, key string, value unsafe.Pointer) bool {
keyVal := C.CString(key)
defer C.free(unsafe.Pointer(keyVal))
rv := C.PDFDictionaryGetArray(
// *typing.RefType
unsafe.Pointer(dict),
// *typing.CStringType
keyVal,
// *typing.RefType
unsafe.Pointer(document),
// *typing.PointerType
(*C.uint8_t)(unsafe.Pointer(password)),
unsafe.Pointer(value),
)
// *typing.PrimitiveType
return bool(rv)
Expand Down
14 changes: 9 additions & 5 deletions macos/coregraphics/functions.gen.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// AUTO-GENERATED CODE, DO NOT MODIFY

#import "CoreGraphics/CoreGraphics.h"
void * ColorSpaceCreateCalibratedGray(float* whitePoint, float* blackPoint, float gamma) {
return (void *)CGColorSpaceCreateCalibratedGray(whitePoint, blackPoint, gamma);
}
BOOL PDFDocumentUnlockWithPassword(void * document, uint8_t* password) {
return (BOOL)CGPDFDocumentUnlockWithPassword(document, password);
bool PDFDictionaryGetArray(void * dict, char* key, void * value) {
return (bool)CGPDFDictionaryGetArray(
// *typing.RefType
(CGPDFDictionaryRef*)dict,
// *typing.CStringType
(char*)key,
// *typing.RefType
(CGPDFArrayRef*)value
);
}

0 comments on commit 6ced417

Please sign in to comment.