Skip to content

Commit 7c9ab4d

Browse files
committed
macdriver => darwinkit
1 parent 23a7953 commit 7c9ab4d

File tree

2,471 files changed

+4034
-4033
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,471 files changed

+4034
-4033
lines changed

Diff for: README.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
<img src="https://github.com/progrium/macdriver/raw/main/macdriver.gif" alt="MacDriver Logo">
1+
<img src="https://github.com/progrium/darwinkit/raw/main/macdriver.gif" alt="DarwinKit Logo">
22

33
Native Apple APIs for Golang!
44

5-
[![GoDoc](https://godoc.org/github.com/progrium/macdriver?status.svg)](https://pkg.go.dev/github.com/progrium/macdriver@main)
6-
[![Go Report Card](https://goreportcard.com/badge/github.com/progrium/macdriver)](https://goreportcard.com/report/github.com/progrium/macdriver)
5+
[![GoDoc](https://godoc.org/github.com/progrium/darwinkit?status.svg)](https://pkg.go.dev/github.com/progrium/darwinkit@main)
6+
[![Go Report Card](https://goreportcard.com/badge/github.com/progrium/darwinkit)](https://goreportcard.com/report/github.com/progrium/darwinkit)
77
<a href="https://twitter.com/progrium" title="@progrium on Twitter"><img src="https://img.shields.io/badge/[email protected]" alt="@progrium on Twitter"></a>
8-
<a href="https://github.com/progrium/macdriver/discussions" title="Project Forum"><img src="https://img.shields.io/badge/community-forum-ff69b4.svg" alt="Project Forum"></a>
8+
<a href="https://github.com/progrium/darwinkit/discussions" title="Project Forum"><img src="https://img.shields.io/badge/community-forum-ff69b4.svg" alt="Project Forum"></a>
99
<a href="https://github.com/sponsors/progrium" title="Sponsor Project"><img src="https://img.shields.io/static/v1?label=sponsor&message=%E2%9D%A4&logo=GitHub" alt="Sponsor Project" /></a>
1010

1111
> [!IMPORTANT]
12-
> June 13, 2024: **MacDriver is now DarwinKit and we're about to release 0.5.0!** The [legacy branch](https://github.com/progrium/macdriver/tree/legacy) and [previous releases](https://github.com/progrium/macdriver/releases) are still available for existing code to work against. Use `main` until 0.5.0 is released.
12+
> June 13, 2024: **MacDriver is now DarwinKit and we're about to release 0.5.0!** The [legacy branch](https://github.com/progrium/darwinkit/tree/legacy) and [previous releases](https://github.com/progrium/darwinkit/releases) are still available for existing code to work against. Use `main` until 0.5.0 is released.
1313
1414
------
1515

16-
DarwinKit lets you work with [supported Apple frameworks](https://pkg.go.dev/github.com/progrium/macdriver/macos@main#section-directories) and build native applications using Go. With XCode and Go 1.18+ installed, you can write this program in a `main.go` file:
16+
DarwinKit lets you work with [supported Apple frameworks](https://pkg.go.dev/github.com/progrium/darwinkit/macos@main#section-directories) and build native applications using Go. With XCode and Go 1.18+ installed, you can write this program in a `main.go` file:
1717

1818
```go
1919
package main
2020

2121
import (
22-
"github.com/progrium/macdriver/objc"
23-
"github.com/progrium/macdriver/macos"
24-
"github.com/progrium/macdriver/macos/appkit"
25-
"github.com/progrium/macdriver/macos/foundation"
26-
"github.com/progrium/macdriver/macos/webkit"
22+
"github.com/progrium/darwinkit/objc"
23+
"github.com/progrium/darwinkit/macos"
24+
"github.com/progrium/darwinkit/macos/appkit"
25+
"github.com/progrium/darwinkit/macos/foundation"
26+
"github.com/progrium/darwinkit/macos/webkit"
2727
)
2828

2929
func main() {
@@ -60,7 +60,7 @@ Then in this directory run:
6060

6161
```
6262
go mod init helloworld
63-
go get github.com/progrium/macdriver@main
63+
go get github.com/progrium/darwinkit@main
6464
go run main.go
6565
```
6666

@@ -74,7 +74,7 @@ Although currently outside the scope of this project, if you wanted you could pu
7474
* Your programs link against the actual Apple frameworks using [cgo](https://pkg.go.dev/cmd/cgo), so XCode needs to be installed for the framework headers.
7575
* You will be using two memory management systems. Framework objects are managed by [Objective-C memory management](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html#//apple_ref/doc/uid/10000011-SW1), so be sure to read our docs on [memory management](docs/memorymanagement.md) with DarwinKit.
7676
* Exceptions in frameworks will segfault, giving you both an Objective-C stacktrace and a Go panic stacktrace. You will be debugging a hybrid Go and Objective-C program.
77-
* Goroutines that interact with GUI objects need to [dispatch](https://pkg.go.dev/github.com/progrium/macdriver@main/dispatch) operations on the main thread otherwise it will segfault.
77+
* Goroutines that interact with GUI objects need to [dispatch](https://pkg.go.dev/github.com/progrium/darwinkit@main/dispatch) operations on the main thread otherwise it will segfault.
7878

7979
This is all tenable for simple programs, but these are the reasons we don't *recommend* large/complex programs using DarwinKit.
8080

@@ -131,7 +131,7 @@ call in Go, the `objc` package receives it as a raw pointer, which it first puts
131131
bindings for a class define a struct type that embeds an `objc.Object` struct, which contains a single
132132
field to hold the `unsafe.Pointer`. So unless working with a primitive type, you're working with an `unsafe.Pointer` wrapped in an `objc.Object` wrapped in a struct type that has the methods for the class of the object of the pointer. Be sure to read our documentation on [memory management](docs/memorymanagement.md).
133133

134-
If you have questions, feel free to ask in the [discussion forums](https://github.com/progrium/macdriver/discussions).
134+
If you have questions, feel free to ask in the [discussion forums](https://github.com/progrium/darwinkit/discussions).
135135

136136
## Thanks
137137

Diff for: docs/memorymanagement.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Working with Objective-C from Go requires understanding how [Objective-C memory
66

77
ARC is a feature of the Objective-C compiler, which does not compile Go code. Therefore memory management of Objective-C objects in Go is done with MMR. DarwinKit continues the policy of "the code that allocates is the code responsible for releasing" so unless you explicitly call the `Alloc()` method, you can assume `Autorelease()` has been called on the object unless documented otherwise.
88

9-
This applies to the Go-style constructors made for classes, which are the functions prefixed with "New". This also means all code should be run in an autorelease pool. This is already the case for most delegates and callbacks since these are called from the AppKit event loop, which has an autorelease pool for every cycle of the loop. Code outside this loop (such as code run before appkit.Application is run, or code in a goroutine) should be wrapped in [objc.WithAutoreleasePool](https://pkg.go.dev/github.com/progrium/macdriver@main/objc#WithAutoreleasePool).
9+
This applies to the Go-style constructors made for classes, which are the functions prefixed with "New". This also means all code should be run in an autorelease pool. This is already the case for most delegates and callbacks since these are called from the AppKit event loop, which has an autorelease pool for every cycle of the loop. Code outside this loop (such as code run before appkit.Application is run, or code in a goroutine) should be wrapped in [objc.WithAutoreleasePool](https://pkg.go.dev/github.com/progrium/darwinkit@main/objc#WithAutoreleasePool).
1010

11-
Objects that you want to retain should be passed by reference to [objc.Retain](https://pkg.go.dev/github.com/progrium/macdriver@main/objc#Retain). Using this instead of the object's `Retain()` method directly will let the Go GC know it should release the object before cleaning it up. Objects that only need to exist within the current event cycle don't need to be retained. Objects passed to other objects that need to be retained by them should be retained by the receiving object. If you get an unexplained segfault, chances are an object needed to be retained. A common situation for this are appkit.Windows you create.
11+
Objects that you want to retain should be passed by reference to [objc.Retain](https://pkg.go.dev/github.com/progrium/darwinkit@main/objc#Retain). Using this instead of the object's `Retain()` method directly will let the Go GC know it should release the object before cleaning it up. Objects that only need to exist within the current event cycle don't need to be retained. Objects passed to other objects that need to be retained by them should be retained by the receiving object. If you get an unexplained segfault, chances are an object needed to be retained. A common situation for this are appkit.Windows you create.
1212

1313
### Full Explanation
1414

Diff for: generate/class.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"log"
66
"strings"
77

8-
"github.com/progrium/macdriver/generate/codegen"
9-
"github.com/progrium/macdriver/generate/modules"
10-
"github.com/progrium/macdriver/generate/typing"
8+
"github.com/progrium/darwinkit/generate/codegen"
9+
"github.com/progrium/darwinkit/generate/modules"
10+
"github.com/progrium/darwinkit/generate/typing"
1111
)
1212

1313
func (db *Generator) ToClassGen(sym Symbol) *codegen.Class {

Diff for: generate/codegen/aliasinfo.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package codegen
22

33
import (
4-
"github.com/progrium/macdriver/generate/modules"
5-
"github.com/progrium/macdriver/generate/typing"
4+
"github.com/progrium/darwinkit/generate/modules"
5+
"github.com/progrium/darwinkit/generate/typing"
66
)
77

88
// AliasInfo enum type and values

Diff for: generate/codegen/codegen.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package codegen
22

3-
import "github.com/progrium/macdriver/internal/set"
3+
import "github.com/progrium/darwinkit/internal/set"
44

55
var AutoGeneratedMark = "// Code generated by DarwinKit. DO NOT EDIT.\n"
66

Diff for: generate/codegen/filewriter.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"path/filepath"
66
"strings"
77

8-
"github.com/progrium/macdriver/generate/modules"
9-
"github.com/progrium/macdriver/internal/set"
10-
"github.com/progrium/macdriver/internal/stringx"
8+
"github.com/progrium/darwinkit/generate/modules"
9+
"github.com/progrium/darwinkit/internal/set"
10+
"github.com/progrium/darwinkit/internal/stringx"
1111
)
1212

1313
// TypeWriter write codes for a go file
@@ -42,10 +42,10 @@ func (w *FileWriter) WriteCode() {
4242
for _, tc := range w.typeCodes {
4343
imports.AddSet(tc.GoImports())
4444
}
45-
selfPackage := "github.com/progrium/macdriver/macos/" + w.Module.Package
45+
selfPackage := "github.com/progrium/darwinkit/macos/" + w.Module.Package
4646
cw.Indent()
4747
imports.ForEach(func(value string) {
48-
if value != selfPackage && value != "github.com/progrium/macdriver/macos/objc" {
48+
if value != selfPackage && value != "github.com/progrium/darwinkit/macos/objc" {
4949
cw.WriteLine("\"" + value + "\"")
5050
}
5151
})

Diff for: generate/codegen/gen_class.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"fmt"
55
"strings"
66

7-
"github.com/progrium/macdriver/generate/typing"
8-
"github.com/progrium/macdriver/internal/set"
7+
"github.com/progrium/darwinkit/generate/typing"
8+
"github.com/progrium/darwinkit/internal/set"
99
)
1010

1111
// Class is code generator for objc class
@@ -116,9 +116,9 @@ func (c *Class) Init() {
116116
}
117117

118118
func (c *Class) GoImports() set.Set[string] {
119-
imports := set.New("github.com/progrium/macdriver/objc")
119+
imports := set.New("github.com/progrium/darwinkit/objc")
120120
if c.Super != nil {
121-
imports.Add("github.com/progrium/macdriver/macos/" + c.Super.Type.Module.Package)
121+
imports.Add("github.com/progrium/darwinkit/macos/" + c.Super.Type.Module.Package)
122122
}
123123
for _, m := range c.InstanceTypeMethods {
124124
im := m.NormalizeInstanceTypeMethod(c.Type)

Diff for: generate/codegen/gen_method.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"fmt"
55
"strings"
66

7-
"github.com/progrium/macdriver/internal/set"
8-
"github.com/progrium/macdriver/internal/stringx"
7+
"github.com/progrium/darwinkit/internal/set"
8+
"github.com/progrium/darwinkit/internal/stringx"
99

10-
"github.com/progrium/macdriver/generate/modules"
11-
"github.com/progrium/macdriver/generate/typing"
10+
"github.com/progrium/darwinkit/generate/modules"
11+
"github.com/progrium/darwinkit/generate/typing"
1212
)
1313

1414
// Method is code generator for objective-c method
@@ -246,7 +246,7 @@ func (m *Method) ProtocolGoFuncName() string {
246246

247247
// GoImports return all imports for go file
248248
func (m *Method) GoImports() set.Set[string] {
249-
var imports = set.New("github.com/progrium/macdriver/objc")
249+
var imports = set.New("github.com/progrium/darwinkit/objc")
250250
for _, param := range m.Params {
251251
imports.AddSet(param.Type.GoImports())
252252
}

Diff for: generate/codegen/gen_param.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package codegen
22

33
import (
4-
"github.com/progrium/macdriver/generate/modules"
5-
"github.com/progrium/macdriver/generate/typing"
4+
"github.com/progrium/darwinkit/generate/modules"
5+
"github.com/progrium/darwinkit/generate/typing"
66
)
77

88
// Param is code generator for objective-c method param

Diff for: generate/codegen/gen_property.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package codegen
33
import (
44
"strings"
55

6-
"github.com/progrium/macdriver/generate/typing"
7-
"github.com/progrium/macdriver/internal/stringx"
6+
"github.com/progrium/darwinkit/generate/typing"
7+
"github.com/progrium/darwinkit/internal/stringx"
88
)
99

1010
// Property is code generator for objective-c property

Diff for: generate/codegen/gen_protocol.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"fmt"
66
"strings"
77

8-
"github.com/progrium/macdriver/generate/typing"
9-
"github.com/progrium/macdriver/internal/set"
8+
"github.com/progrium/darwinkit/generate/typing"
9+
"github.com/progrium/darwinkit/internal/set"
1010
)
1111

1212
var _ CodeGen = (*Protocol)(nil)
@@ -92,9 +92,9 @@ func (p *Protocol) Init() {
9292
}
9393

9494
func (p *Protocol) GoImports() set.Set[string] {
95-
imports := set.New("github.com/progrium/macdriver/objc")
95+
imports := set.New("github.com/progrium/darwinkit/objc")
9696
for _, parent := range p.Supers {
97-
imports.Add("github.com/progrium/macdriver/macos/" + parent.Type.Module.Package)
97+
imports.Add("github.com/progrium/darwinkit/macos/" + parent.Type.Module.Package)
9898
}
9999
for _, m := range p.Methods {
100100
imports.AddSet(m.GoImports())

Diff for: generate/codegen/modulewriter.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
"sort"
1010
"strings"
1111

12-
"github.com/progrium/macdriver/generate/modules"
13-
"github.com/progrium/macdriver/generate/typing"
14-
"github.com/progrium/macdriver/internal/set"
12+
"github.com/progrium/darwinkit/generate/modules"
13+
"github.com/progrium/darwinkit/generate/typing"
14+
"github.com/progrium/darwinkit/internal/set"
1515
)
1616

1717
// ModuleWriter mantains module level auto-generated code source files
@@ -71,7 +71,7 @@ func (m *ModuleWriter) WriteTypeAliases() {
7171
}
7272
cw.Indent()
7373
imports.ForEach(func(value string) {
74-
if value != "github.com/progrium/macdriver/macos/objc" {
74+
if value != "github.com/progrium/darwinkit/macos/objc" {
7575
cw.WriteLine("\"" + value + "\"")
7676
}
7777
})
@@ -150,7 +150,7 @@ func (m *ModuleWriter) WriteEnumAliases() {
150150
cw.WriteLine("import (")
151151
cw.Indent()
152152
imports.ForEach(func(value string) {
153-
if value != "github.com/progrium/macdriver/macos/objc" {
153+
if value != "github.com/progrium/darwinkit/macos/objc" {
154154
cw.WriteLine("\"" + value + "\"")
155155
}
156156
})

Diff for: generate/declparse/keywords/init.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package keywords
22

33
import (
4-
"github.com/progrium/macdriver/generate/declparse/lexer"
4+
"github.com/progrium/darwinkit/generate/declparse/lexer"
55
)
66

77
func init() {

Diff for: generate/declparse/parser.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"io"
77
"strings"
88

9-
"github.com/progrium/macdriver/generate/declparse/keywords"
10-
"github.com/progrium/macdriver/generate/declparse/lexer"
9+
"github.com/progrium/darwinkit/generate/declparse/keywords"
10+
"github.com/progrium/darwinkit/generate/declparse/lexer"
1111
)
1212

1313
type Hint int

Diff for: generate/declparse/parser_enum.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package declparse
33
import (
44
"fmt"
55

6-
"github.com/progrium/macdriver/generate/declparse/keywords"
7-
"github.com/progrium/macdriver/generate/declparse/lexer"
6+
"github.com/progrium/darwinkit/generate/declparse/keywords"
7+
"github.com/progrium/darwinkit/generate/declparse/lexer"
88
)
99

1010
func parseEnum(p *Parser) (next stateFn, node Node, err error) {

Diff for: generate/declparse/parser_functype.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package declparse
33
import (
44
"fmt"
55

6-
"github.com/progrium/macdriver/generate/declparse/lexer"
6+
"github.com/progrium/darwinkit/generate/declparse/lexer"
77
)
88

99
func (p *Parser) expectFuncType(returnType *TypeInfo, isTopLevel bool) (fn *FunctionDecl, err error) {

Diff for: generate/declparse/parser_interface.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package declparse
22

33
import (
4-
"github.com/progrium/macdriver/generate/declparse/keywords"
5-
"github.com/progrium/macdriver/generate/declparse/lexer"
4+
"github.com/progrium/darwinkit/generate/declparse/keywords"
5+
"github.com/progrium/darwinkit/generate/declparse/lexer"
66
)
77

88
func parseInterface(p *Parser) (next stateFn, node Node, err error) {

Diff for: generate/declparse/parser_method.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package declparse
33
import (
44
"fmt"
55

6-
"github.com/progrium/macdriver/generate/declparse/lexer"
6+
"github.com/progrium/darwinkit/generate/declparse/lexer"
77
)
88

99
func parseMethod(p *Parser) (next stateFn, node Node, err error) {

Diff for: generate/declparse/parser_property.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package declparse
33
import (
44
"fmt"
55

6-
"github.com/progrium/macdriver/generate/declparse/keywords"
7-
"github.com/progrium/macdriver/generate/declparse/lexer"
6+
"github.com/progrium/darwinkit/generate/declparse/keywords"
7+
"github.com/progrium/darwinkit/generate/declparse/lexer"
88
)
99

1010
func parseProperty(p *Parser) (next stateFn, node Node, err error) {

Diff for: generate/declparse/parser_protocol.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package declparse
22

33
import (
4-
"github.com/progrium/macdriver/generate/declparse/keywords"
5-
"github.com/progrium/macdriver/generate/declparse/lexer"
4+
"github.com/progrium/darwinkit/generate/declparse/keywords"
5+
"github.com/progrium/darwinkit/generate/declparse/lexer"
66
)
77

88
func parseProtocol(p *Parser) (next stateFn, node Node, err error) {

Diff for: generate/declparse/parser_struct.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package declparse
22

33
import (
4-
"github.com/progrium/macdriver/generate/declparse/keywords"
5-
"github.com/progrium/macdriver/generate/declparse/lexer"
4+
"github.com/progrium/darwinkit/generate/declparse/keywords"
5+
"github.com/progrium/darwinkit/generate/declparse/lexer"
66
)
77

88
func parseStruct(p *Parser) (next stateFn, node Node, err error) {

Diff for: generate/declparse/parser_type.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package declparse
22

33
import (
4-
"github.com/progrium/macdriver/generate/declparse/lexer"
4+
"github.com/progrium/darwinkit/generate/declparse/lexer"
55
)
66

77
func (p *Parser) expectType(parens bool) (ti *TypeInfo, err error) {

Diff for: generate/declparse/parser_variable.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package declparse
33
import (
44
"strings"
55

6-
"github.com/progrium/macdriver/generate/declparse/lexer"
6+
"github.com/progrium/darwinkit/generate/declparse/lexer"
77
)
88

99
func parseVariable(p *Parser) (next stateFn, node Node, err error) {

Diff for: generate/enums.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package generate
33
import (
44
"strings"
55

6-
"github.com/progrium/macdriver/generate/codegen"
7-
"github.com/progrium/macdriver/generate/modules"
8-
"github.com/progrium/macdriver/generate/typing"
9-
"github.com/progrium/macdriver/internal/stringx"
6+
"github.com/progrium/darwinkit/generate/codegen"
7+
"github.com/progrium/darwinkit/generate/modules"
8+
"github.com/progrium/darwinkit/generate/typing"
9+
"github.com/progrium/darwinkit/internal/stringx"
1010
)
1111

1212
func (db *Generator) ToEnumInfo(fw string, sym Symbol) *codegen.AliasInfo {

0 commit comments

Comments
 (0)