From cb59698b08002125859cf3ac4203a5ce8d3cf451 Mon Sep 17 00:00:00 2001 From: Travis Cline Date: Mon, 21 Aug 2023 03:09:29 -0700 Subject: [PATCH] generate: iterate on function support --- generate/codegen/gen_function.go | 19 +++- generate/codegen/gen_struct.go | 2 +- generate/codegen/modulewriter.go | 38 ++++++-- generate/function.go | 3 +- generate/generator.go | 6 +- generate/struct.go | 7 +- generate/types.go | 21 +++-- generate/typing/ref_type.go | 18 ++-- macos/coregraphics/aliastypes.gen.go | 14 +-- macos/coregraphics/functions.gen.go | 20 +++-- macos/coregraphics/functions.gen.m | 9 ++ macos/coregraphics/functions.m | 6 -- macos/coregraphics/structs.gen.go | 128 ++++++++++++++++++++------- macos/coregraphics/x_test.go | 13 +++ 14 files changed, 226 insertions(+), 78 deletions(-) create mode 100644 macos/coregraphics/functions.gen.m delete mode 100644 macos/coregraphics/functions.m create mode 100644 macos/coregraphics/x_test.go diff --git a/generate/codegen/gen_function.go b/generate/codegen/gen_function.go index 703f38cd..1ab102c8 100644 --- a/generate/codegen/gen_function.go +++ b/generate/codegen/gen_function.go @@ -47,6 +47,7 @@ func (f *Function) GoReturn(currentModule *modules.Module) string { if f.ReturnType == nil { return "" } + log.Printf("rendering GoReturn function return: %s %T", f.ReturnType, f.ReturnType) return f.ReturnType.GoName(currentModule, true) } @@ -127,10 +128,26 @@ func (f *Function) WriteGoCallCode(currentModule *modules.Module, cw *CodeWriter cw.WriteLine("}") } +func (f *Function) WriteObjcWrapper(currentModule *modules.Module, cw *CodeWriter) { + if f.Deprecated { + return + cw.WriteLine("// deprecated") + } + returnTypeStr := f.Type.ReturnType.CName() + cw.WriteLineF("%v %v(%v) {", returnTypeStr, f.GoName, f.CArgs(currentModule)) + cw.Indent() + var args []string + for _, p := range f.Parameters { + args = append(args, p.Name) + } + cw.WriteLineF("return %v(%v);", f.Type.Name, strings.Join(args, ", ")) + cw.UnIndent() + cw.WriteLine("}") +} + func (f *Function) WriteCSignature(currentModule *modules.Module, cw *CodeWriter) { var returnTypeStr string rt := f.Type.ReturnType - log.Printf("rt: %T", rt) returnTypeStr = rt.CName() cw.WriteLineF("// %v %v(%v); ", returnTypeStr, f.GoName, f.CArgs(currentModule)) } diff --git a/generate/codegen/gen_struct.go b/generate/codegen/gen_struct.go index baf2b5c8..3b14c17a 100644 --- a/generate/codegen/gen_struct.go +++ b/generate/codegen/gen_struct.go @@ -6,7 +6,7 @@ import ( // Struct is code generator for objective-c struct type Struct struct { - Type *typing.StructType + Type typing.Type Name string // the first part of objc function name GoName string Deprecated bool // if has been deprecated diff --git a/generate/codegen/modulewriter.go b/generate/codegen/modulewriter.go index d34e5bab..f17580e9 100644 --- a/generate/codegen/modulewriter.go +++ b/generate/codegen/modulewriter.go @@ -33,6 +33,7 @@ func (m *ModuleWriter) WriteCode() { m.WriteTypeAliases() m.WriteStructs() m.WriteFunctions() + m.WriteFunctionWrappers() if m.Module.Package == "coreimage" { // filter protocols maybe arent "real" protocols? // get "cannot find protocol declaration" with protocol imports @@ -117,19 +118,20 @@ func (m *ModuleWriter) WriteStructs() { cw.WriteLine(")") for _, s := range m.Structs { - if s.DocURL != "" { - cw.WriteLine(fmt.Sprintf("// %s [Full Topic]", s.Description)) - cw.WriteLine(fmt.Sprintf("//\n// [Full Topic]: %s", s.DocURL)) - } - // if Ref type, allias to unsafe.Pointer if strings.HasSuffix(s.Name, "Ref") { + if s.DocURL != "" { + cw.WriteLine(fmt.Sprintf("// %s [Full Topic]", s.Description)) + cw.WriteLine(fmt.Sprintf("//\n// [Full Topic]: %s", s.DocURL)) + } + cw.WriteLineF("type %s unsafe.Pointer", s.GoName) continue } } } +// WriteFunctions writes the go code to call exposed functions. func (m *ModuleWriter) WriteFunctions() { if len(m.Functions) == 0 { return @@ -177,6 +179,32 @@ func (m *ModuleWriter) WriteFunctions() { } } +// WriteFunctionWrappers writes the objc code to wrap exposed functions. +// The cgo type system is unaware of objective c types so these wrappers must exist to allow +// us to call the functions and return appropritely. +func (m *ModuleWriter) WriteFunctionWrappers() { + if len(m.Functions) == 0 { + return + } + + filePath := filepath.Join(m.PlatformDir, m.Module.Package, "functions.gen.m") + os.MkdirAll(filepath.Dir(filePath), 0755) + f, err := os.Create(filePath) + if err != nil { + panic(err) + } + defer f.Close() + + cw := &CodeWriter{Writer: f, IndentStr: "\t"} + cw.WriteLine(AutoGeneratedMark) + + //TODO: determine appropriate imports + cw.WriteLineF("#import \"%s\"", m.Module.Header) + for _, f := range m.Functions { + f.WriteObjcWrapper(&m.Module, cw) + } +} + func (m *ModuleWriter) WriteEnumAliases() { enums := make([]*AliasInfo, len(m.EnumAliases)) copy(enums, m.EnumAliases) diff --git a/generate/function.go b/generate/function.go index 06cff6cd..5d36a1e9 100644 --- a/generate/function.go +++ b/generate/function.go @@ -5,6 +5,7 @@ import ( "log" "github.com/progrium/macdriver/generate/codegen" + "github.com/progrium/macdriver/generate/modules" "github.com/progrium/macdriver/generate/typing" ) @@ -253,7 +254,7 @@ func (db *Generator) ToFunction(fw string, sym Symbol) *codegen.Function { } fn := &codegen.Function{ Name: sym.Name, - GoName: sym.Name, + GoName: modules.TrimPrefix(sym.Name), Description: sym.Description, DocURL: sym.DocURL(), Type: fntyp, diff --git a/generate/generator.go b/generate/generator.go index e7a292d0..abfb8e6c 100644 --- a/generate/generator.go +++ b/generate/generator.go @@ -113,11 +113,11 @@ func (db *Generator) Generate(platform string, version int, rootDir string, fram } mw.Functions = append(mw.Functions, fn) case "Struct": - fn := db.ToStruct(framework, s) - if fn == nil { + s := db.ToStruct(framework, s) + if s == nil { continue } - mw.Structs = append(mw.Structs, fn) + mw.Structs = append(mw.Structs, s) } } mw.WriteCode() diff --git a/generate/struct.go b/generate/struct.go index 87fa8760..1801377b 100644 --- a/generate/struct.go +++ b/generate/struct.go @@ -5,7 +5,6 @@ import ( "github.com/progrium/macdriver/generate/codegen" "github.com/progrium/macdriver/generate/modules" - "github.com/progrium/macdriver/generate/typing" ) func (db *Generator) ToStruct(fw string, sym Symbol) *codegen.Struct { @@ -16,16 +15,12 @@ func (db *Generator) ToStruct(fw string, sym Symbol) *codegen.Struct { return nil } typ := db.TypeFromSymbol(sym) - styp, ok := typ.(*typing.StructType) - if !ok { - return nil - } s := &codegen.Struct{ Name: sym.Name, GoName: modules.TrimPrefix(sym.Name), Description: sym.Description, DocURL: sym.DocURL(), - Type: styp, + Type: typ, } return s diff --git a/generate/types.go b/generate/types.go index 649cae39..e5b15766 100644 --- a/generate/types.go +++ b/generate/types.go @@ -48,7 +48,8 @@ func (db *Generator) TypeFromSymbol(sym Symbol) typing.Type { } case "Union": return &typing.RefType{ - Name: sym.Name, + Name: sym.Name, + GName: modules.TrimPrefix(sym.Name), } case "Type": if sym.Type != "Type Alias" { @@ -60,7 +61,8 @@ func (db *Generator) TypeFromSymbol(sym Symbol) typing.Type { // sym.Name == "NSZone" || sym.Name == "MusicSequence" { return &typing.RefType{ - Name: sym.Name, + Name: sym.Name, + GName: modules.TrimPrefix(sym.Name), } } st, err := sym.Parse() @@ -70,7 +72,8 @@ func (db *Generator) TypeFromSymbol(sym Symbol) typing.Type { } if st.Struct != nil { return &typing.RefType{ - Name: st.Struct.Name, + Name: st.Struct.Name, + GName: modules.TrimPrefix(sym.Name), } } if st.TypeAlias == nil { @@ -91,7 +94,9 @@ func (db *Generator) TypeFromSymbol(sym Symbol) typing.Type { case "Struct": if strings.HasSuffix(sym.Name, "Ref") { return &typing.RefType{ - Name: sym.Name, + Name: sym.Name, + GName: modules.TrimPrefix(sym.Name), + Module: modules.Get(module), } } return &typing.StructType{ @@ -100,7 +105,8 @@ func (db *Generator) TypeFromSymbol(sym Symbol) typing.Type { Module: modules.Get(module), } case "Function": - if sym.Name != "CGDisplayCreateImage" { + if sym.Name != "CGDisplayCreateImage" && + sym.Name != "CGMainDisplayID" { return nil } typ, err := sym.Parse() @@ -219,7 +225,10 @@ func (db *Generator) ParseType(ti declparse.TypeInfo) (typ typing.Type) { } ref = true case "NSZone", "ipc_port_t": - typ = &typing.RefType{Name: ti.Name} + typ = &typing.RefType{ + Name: ti.Name, + GName: modules.TrimPrefix(ti.Name), + } ref = true case "NSDictionary": dt := &typing.DictType{} diff --git a/generate/typing/ref_type.go b/generate/typing/ref_type.go index 6875f638..f976a7c8 100644 --- a/generate/typing/ref_type.go +++ b/generate/typing/ref_type.go @@ -8,17 +8,23 @@ import ( // for weird struct refs like those ending in "Ref" type RefType struct { - Name string // c and objc type name - // GName string // the go struct name - // Module *modules.Module // the module + Name string // c and objc type name + GName string // the go struct name + Module *modules.Module // the module } func (s *RefType) GoImports() set.Set[string] { - return set.New("unsafe") + if s.Module == nil { + return set.New("unsafe") + } + return set.New("github.com/progrium/macdriver/macos/" + s.Module.Package) } func (s *RefType) GoName(currentModule *modules.Module, receiveFromObjc bool) string { - return "unsafe.Pointer" + if s.Module == nil { + return "unsafe.Pointer" + } + return FullGoName(*s.Module, s.GName, *currentModule) } func (s *RefType) ObjcName() string { @@ -30,5 +36,5 @@ func (s *RefType) CName() string { } func (s *RefType) DeclareModule() *modules.Module { - return nil + return s.Module } diff --git a/macos/coregraphics/aliastypes.gen.go b/macos/coregraphics/aliastypes.gen.go index f62d2b7b..19bc6133 100644 --- a/macos/coregraphics/aliastypes.gen.go +++ b/macos/coregraphics/aliastypes.gen.go @@ -5,6 +5,8 @@ package coregraphics import ( "unsafe" + "github.com/progrium/macdriver/macos/corefoundation" + "github.com/progrium/macdriver/macos/iosurface" "github.com/progrium/macdriver/objc" ) @@ -46,12 +48,12 @@ type DataProviderReleaseBytePointerCallback = func(info unsafe.Pointer, pointer // Draws a pattern cell. [Full Topic] // // [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgpatterndrawpatterncallback?language=objc -type PatternDrawPatternCallback = func(info unsafe.Pointer, context unsafe.Pointer) +type PatternDrawPatternCallback = func(info unsafe.Pointer, context ContextRef) // Passes messages generated during a PostScript conversion process. [Full Topic] // // [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgpsconvertermessagecallback?language=objc -type PSConverterMessageCallback = func(info unsafe.Pointer, message unsafe.Pointer) +type PSConverterMessageCallback = func(info unsafe.Pointer, message corefoundation.StringRef) // A client-supplied callback function that’s invoked whenever the configuration of a local display is changed. [Full Topic] // @@ -66,7 +68,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 unsafe.Pointer, userInfo unsafe.Pointer) unsafe.Pointer +type EventTapCallBack = func(proxy unsafe.Pointer, type_ EventType, event EventRef, userInfo unsafe.Pointer) EventRef // Copies data from a Core Graphics-supplied buffer into a data consumer. [Full Topic] // @@ -111,7 +113,7 @@ type PSConverterReleaseInfoCallback = func(info unsafe.Pointer) // Performs custom tasks at the beginning of each page in a PostScript conversion process. [Full Topic] // // [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgpsconverterbeginpagecallback?language=objc -type PSConverterBeginPageCallback = func(info unsafe.Pointer, pageNumber uint, pageInfo unsafe.Pointer) +type PSConverterBeginPageCallback = func(info unsafe.Pointer, pageNumber uint, pageInfo corefoundation.DictionaryRef) // Performs custom clean-up tasks when Core Graphics deallocates a CGFunctionRef object. [Full Topic] // @@ -136,12 +138,12 @@ type ErrorCallback = func() // Performs custom tasks at the end of each page of a PostScript conversion process. [Full Topic] // // [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgpsconverterendpagecallback?language=objc -type PSConverterEndPageCallback = func(info unsafe.Pointer, pageNumber uint, pageInfo unsafe.Pointer) +type PSConverterEndPageCallback = func(info unsafe.Pointer, pageNumber uint, pageInfo corefoundation.DictionaryRef) // A block called when a data stream has a new frame event to process. [Full Topic] // // [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgdisplaystreamframeavailablehandler?language=objc -type DisplayStreamFrameAvailableHandler = func(status DisplayStreamFrameStatus, displayTime uint64, frameSurface unsafe.Pointer, updateRef unsafe.Pointer) +type DisplayStreamFrameAvailableHandler = func(status DisplayStreamFrameStatus, displayTime uint64, frameSurface iosurface.Ref, updateRef DisplayStreamUpdateRef) // Performs custom operations on the supplied input data to produce output data. [Full Topic] // diff --git a/macos/coregraphics/functions.gen.go b/macos/coregraphics/functions.gen.go index 6957d1be..4dfd93bb 100644 --- a/macos/coregraphics/functions.gen.go +++ b/macos/coregraphics/functions.gen.go @@ -6,16 +6,22 @@ package coregraphics // #import // #import // #import -// void * CGDisplayCreateImage(uint32_t displayID); +// uint32_t MainDisplayID(); +// void * DisplayCreateImage(uint32_t displayID); import "C" -import ( - "unsafe" -) + +// Returns the display ID of the main display. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/1455620-cgmaindisplayid?language=objc +func MainDisplayID() DirectDisplayID { + rv := C.MainDisplayID() + return DirectDisplayID(rv) +} // Returns an image containing the contents of the specified display. [Full Topic] // // [Full Topic]: https://developer.apple.com/documentation/coregraphics/1455691-cgdisplaycreateimage?language=objc -func DisplayCreateImage(displayID DirectDisplayID) unsafe.Pointer { - rv := C.CGDisplayCreateImage(C.uint32_t(displayID)) - return unsafe.Pointer(rv) +func DisplayCreateImage(displayID DirectDisplayID) ImageRef { + rv := C.DisplayCreateImage(C.uint32_t(displayID)) + return ImageRef(rv) } diff --git a/macos/coregraphics/functions.gen.m b/macos/coregraphics/functions.gen.m new file mode 100644 index 00000000..a69cc567 --- /dev/null +++ b/macos/coregraphics/functions.gen.m @@ -0,0 +1,9 @@ +// AUTO-GENERATED CODE, DO NOT MODIFY + +#import "CoreGraphics/CoreGraphics.h" +uint32_t MainDisplayID() { + return CGMainDisplayID(); +} +void * DisplayCreateImage(uint32_t displayID) { + return CGDisplayCreateImage(displayID); +} diff --git a/macos/coregraphics/functions.m b/macos/coregraphics/functions.m deleted file mode 100644 index abc96b5f..00000000 --- a/macos/coregraphics/functions.m +++ /dev/null @@ -1,6 +0,0 @@ -#import -#import - -void* DisplayCreateImage(uint32_t displayID) { - return CGDisplayCreateImage(displayID); -} diff --git a/macos/coregraphics/structs.gen.go b/macos/coregraphics/structs.gen.go index 883f725d..588b9fe9 100644 --- a/macos/coregraphics/structs.gen.go +++ b/macos/coregraphics/structs.gen.go @@ -2,48 +2,116 @@ package coregraphics -// A structure that holds a version and two callback functions for drawing a custom pattern. [Full Topic] +import ( + "unsafe" +) + +// A reference to frame update’s metadata. [Full Topic] // -// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgpatterncallbacks?language=objc -// A structure that contains pointers to callback functions that manage the copying of data for a data consumer. [Full Topic] +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgdisplaystreamupdateref?language=objc +type DisplayStreamUpdateRef unsafe.Pointer + +// A profile that specifies how to interpret a color value for display. [Full Topic] // -// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgdataconsumercallbacks?language=objc -// A structure that contains a point in a two-dimensional coordinate system. [Full Topic] +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgcolorspaceref?language=objc +type ColorSpaceRef unsafe.Pointer + +// An abstraction for data-reading tasks that eliminates the need to manage a raw memory buffer. [Full Topic] // -// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgpoint?language=objc -// Defines a structure containing pointers to client-defined callback functions that manage the sending of data for a sequential-access data provider. [Full Topic] +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgdataproviderref?language=objc +type DataProviderRef unsafe.Pointer + +// An opaque data type used to convert PostScript data to PDF data. [Full Topic] // -// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgdataprovidersequentialcallbacks?language=objc -// A structure that contains width and height values. [Full Topic] +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgpsconverterref?language=objc +type PSConverterRef unsafe.Pointer + +// A document that contains PDF (Portable Document Format) drawing information. [Full Topic] // -// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgsize?language=objc -// [Full Topic] +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgpdfdocumentref?language=objc +type PDFDocumentRef unsafe.Pointer + +// A general facility for defining and using callback functions. [Full Topic] // -// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgcolordataformat?language=objc -// The distance, in pixel units, that an onscreen region moves. [Full Topic] +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgfunctionref?language=objc +type FunctionRef unsafe.Pointer + +// An object that describes how to convert between color spaces for use by other system services. [Full Topic] // -// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgscreenupdatemovedelta?language=objc -// Defines pointers to client-defined callback functions that manage the sending of data for a direct-access data provider. [Full Topic] +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgcolorconversioninforef?language=objc +type ColorConversionInfoRef unsafe.Pointer + +// A Quartz 2D drawing environment. [Full Topic] // -// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgdataproviderdirectcallbacks?language=objc -// A structure that contains a two-dimensional vector. [Full Topic] +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgcontextref?language=objc +type ContextRef unsafe.Pointer + +// Defines an opaque type that represents a low-level hardware event. [Full Topic] // -// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgvector?language=objc -// A structure that contains the location and dimensions of a rectangle. [Full Topic] +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgeventref?language=objc +type EventRef unsafe.Pointer + +// A mutable graphics path: a mathematical description of shapes or lines to be drawn in a graphics context. [Full Topic] // -// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgrect?language=objc -// A structure that contains callbacks needed by a CGFunctionRef object. [Full Topic] +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgmutablepathref?language=objc +type MutablePathRef unsafe.Pointer + +// A definition for a smooth transition between colors for drawing radial and axial gradient fills. [Full Topic] // -// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgfunctioncallbacks?language=objc -// A data structure that provides information about a path element. [Full Topic] +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cggradientref?language=objc +type GradientRef unsafe.Pointer + +// A set of character glyphs and layout information for drawing text. [Full Topic] // -// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgpathelement?language=objc -// [Full Topic] +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgfontref?language=objc +type FontRef unsafe.Pointer + +// A reference to a display stream object. [Full Topic] // -// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgdevicecolor?language=objc -// Defines the structure used to report information about event taps. [Full Topic] +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgdisplaystreamref?language=objc +type DisplayStreamRef unsafe.Pointer + +// A set of components that define a color, with a color space specifying how to interpret them. [Full Topic] // -// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgeventtapinformation?language=objc -// A structure for holding the callbacks provided when you create a PostScript converter object. [Full Topic] +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgcolorref?language=objc +type ColorRef unsafe.Pointer + +// A definition for a smooth transition between colors, controlled by a custom function you provide, for drawing radial and axial gradient fills. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgshadingref?language=objc +type ShadingRef unsafe.Pointer + +// A bitmap image or image mask. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgimageref?language=objc +type ImageRef unsafe.Pointer + +// An abstraction for data-writing tasks that eliminates the need to manage a raw memory buffer. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgdataconsumerref?language=objc +type DataConsumerRef unsafe.Pointer + +// A 2D pattern to be used for drawing graphics paths. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgpatternref?language=objc +type PatternRef unsafe.Pointer + +// A reference to a display mode object. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgdisplaymoderef?language=objc +type DisplayModeRef unsafe.Pointer + +// A type that represents a page in a PDF document. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgpdfpageref?language=objc +type PDFPageRef unsafe.Pointer + +// An offscreen context for reusing content drawn with Core Graphics. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cglayerref?language=objc +type LayerRef unsafe.Pointer + +// Defines an opaque type that represents the source of a Quartz event. [Full Topic] // -// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgpsconvertercallbacks?language=objc +// [Full Topic]: https://developer.apple.com/documentation/coregraphics/cgeventsourceref?language=objc +type EventSourceRef unsafe.Pointer diff --git a/macos/coregraphics/x_test.go b/macos/coregraphics/x_test.go new file mode 100644 index 00000000..4dd568e6 --- /dev/null +++ b/macos/coregraphics/x_test.go @@ -0,0 +1,13 @@ +package coregraphics + +import ( + "fmt" + "testing" +) + +func TestFoo(t *testing.T) { + d := MainDisplayID() + fmt.Println("display:", d) + img := DisplayCreateImage(d) + fmt.Println("image:", img) +}