refactor: trim unused public wrapper scaffolding
- commit
- f2f7189c28eb6c0c806001d7d89030023d1c247b
- author
- brice · · 2026-04-09 08:20 UTC
- parent
- b35cd9f
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
5 files · +7 -83
M pipewire/context.go +0 -21
| @@ -1,29 +1,8 @@ | |||
| 1 | 1 | package pipewire | |
| 2 | 2 | ||
| 3 | - | import ( | |
| 4 | - | "github.com/bnema/purego-pipewire/internal/core" | |
| 5 | - | ) | |
| 6 | - | ||
| 7 | 3 | // Context is the public interface for PipeWire context operations. | |
| 8 | 4 | // Contexts manage resources and connections to the PipeWire server. | |
| 9 | 5 | type Context interface { | |
| 10 | 6 | Destroy() | |
| 11 | 7 | Connect() (Core, error) | |
| 12 | 8 | } | |
| 13 | - | ||
| 14 | - | // contextWrapper wraps the internal core.Context to implement the public Context interface. | |
| 15 | - | type contextWrapper struct { | |
| 16 | - | inner *core.Context | |
| 17 | - | } | |
| 18 | - | ||
| 19 | - | func (cw contextWrapper) Destroy() { | |
| 20 | - | cw.inner.Destroy() | |
| 21 | - | } | |
| 22 | - | ||
| 23 | - | func (cw contextWrapper) Connect() (Core, error) { | |
| 24 | - | c, err := cw.inner.Connect() | |
| 25 | - | if err != nil { | |
| 26 | - | return nil, err | |
| 27 | - | } | |
| 28 | - | return coreWrapper{inner: c}, nil | |
| 29 | - | } | |
| @@ -1,29 +1,8 @@ | |||||
| 1 | package pipewire | 1 | package pipewire | ||
| 2 | 2 | ||||
| 3 | - | import ( | |||
| 4 | - | "github.com/bnema/purego-pipewire/internal/core" | |||
| 5 | - | ) | |||
| 6 | - | ||||
| 7 | // Context is the public interface for PipeWire context operations. | 3 | // Context is the public interface for PipeWire context operations. | ||
| 8 | // Contexts manage resources and connections to the PipeWire server. | 4 | // Contexts manage resources and connections to the PipeWire server. | ||
| 9 | type Context interface { | 5 | type Context interface { | ||
| 10 | Destroy() | 6 | Destroy() | ||
| 11 | Connect() (Core, error) | 7 | Connect() (Core, error) | ||
| 12 | } | 8 | } | ||
| 13 | - | ||||
| 14 | - | // contextWrapper wraps the internal core.Context to implement the public Context interface. | |||
| 15 | - | type contextWrapper struct { | |||
| 16 | - | inner *core.Context | |||
| 17 | - | } | |||
| 18 | - | ||||
| 19 | - | func (cw contextWrapper) Destroy() { | |||
| 20 | - | cw.inner.Destroy() | |||
| 21 | - | } | |||
| 22 | - | ||||
| 23 | - | func (cw contextWrapper) Connect() (Core, error) { | |||
| 24 | - | c, err := cw.inner.Connect() | |||
| 25 | - | if err != nil { | |||
| 26 | - | return nil, err | |||
| 27 | - | } | |||
| 28 | - | return coreWrapper{inner: c}, nil | |||
| 29 | - | } | |||
M pipewire/core.go +0 -27
| @@ -2,8 +2,6 @@ package pipewire | |||
| 2 | 2 | ||
| 3 | 3 | import ( | |
| 4 | 4 | "unsafe" | |
| 5 | - | ||
| 6 | - | "github.com/bnema/purego-pipewire/internal/core" | |
| 7 | 5 | ) | |
| 8 | 6 | ||
| 9 | 7 | // Core is the public interface for PipeWire core connection operations. | |
| @@ -13,28 +11,3 @@ type Core interface { | |||
| 13 | 11 | Registry() (Registry, error) | |
| 14 | 12 | NewStream(name string, props unsafe.Pointer) (Stream, error) | |
| 15 | 13 | } | |
| 16 | - | ||
| 17 | - | // coreWrapper wraps the internal core.Core to implement the public Core interface. | |
| 18 | - | type coreWrapper struct { | |
| 19 | - | inner *core.Core | |
| 20 | - | } | |
| 21 | - | ||
| 22 | - | func (cw coreWrapper) Disconnect() { | |
| 23 | - | cw.inner.Disconnect() | |
| 24 | - | } | |
| 25 | - | ||
| 26 | - | func (cw coreWrapper) Registry() (Registry, error) { | |
| 27 | - | r, err := cw.inner.Registry() | |
| 28 | - | if err != nil { | |
| 29 | - | return nil, err | |
| 30 | - | } | |
| 31 | - | return registryWrapper{inner: r}, nil | |
| 32 | - | } | |
| 33 | - | ||
| 34 | - | func (cw coreWrapper) NewStream(name string, props unsafe.Pointer) (Stream, error) { | |
| 35 | - | s, err := cw.inner.NewStream(name, props) | |
| 36 | - | if err != nil { | |
| 37 | - | return nil, err | |
| 38 | - | } | |
| 39 | - | return streamWrapper{inner: s}, nil | |
| 40 | - | } | |
| @@ -2,8 +2,6 @@ package pipewire | |||||
| 2 | 2 | ||||
| 3 | import ( | 3 | import ( | ||
| 4 | "unsafe" | 4 | "unsafe" | ||
| 5 | - | ||||
| 6 | - | "github.com/bnema/purego-pipewire/internal/core" | |||
| 7 | ) | 5 | ) | ||
| 8 | 6 | ||||
| 9 | // Core is the public interface for PipeWire core connection operations. | 7 | // Core is the public interface for PipeWire core connection operations. | ||
| @@ -13,28 +11,3 @@ type Core interface { | |||||
| 13 | Registry() (Registry, error) | 11 | Registry() (Registry, error) | ||
| 14 | NewStream(name string, props unsafe.Pointer) (Stream, error) | 12 | NewStream(name string, props unsafe.Pointer) (Stream, error) | ||
| 15 | } | 13 | } | ||
| 16 | - | ||||
| 17 | - | // coreWrapper wraps the internal core.Core to implement the public Core interface. | |||
| 18 | - | type coreWrapper struct { | |||
| 19 | - | inner *core.Core | |||
| 20 | - | } | |||
| 21 | - | ||||
| 22 | - | func (cw coreWrapper) Disconnect() { | |||
| 23 | - | cw.inner.Disconnect() | |||
| 24 | - | } | |||
| 25 | - | ||||
| 26 | - | func (cw coreWrapper) Registry() (Registry, error) { | |||
| 27 | - | r, err := cw.inner.Registry() | |||
| 28 | - | if err != nil { | |||
| 29 | - | return nil, err | |||
| 30 | - | } | |||
| 31 | - | return registryWrapper{inner: r}, nil | |||
| 32 | - | } | |||
| 33 | - | ||||
| 34 | - | func (cw coreWrapper) NewStream(name string, props unsafe.Pointer) (Stream, error) { | |||
| 35 | - | s, err := cw.inner.NewStream(name, props) | |||
| 36 | - | if err != nil { | |||
| 37 | - | return nil, err | |||
| 38 | - | } | |||
| 39 | - | return streamWrapper{inner: s}, nil | |||
| 40 | - | } | |||
M pipewire/readme_test.go +7 -1
| @@ -2,12 +2,18 @@ package pipewire_test | |||
| 2 | 2 | ||
| 3 | 3 | import ( | |
| 4 | 4 | "os" | |
| 5 | + | "path/filepath" | |
| 6 | + | "runtime" | |
| 5 | 7 | "strings" | |
| 6 | 8 | "testing" | |
| 7 | 9 | ) | |
| 8 | 10 | ||
| 9 | 11 | func TestReadmeMentionsGenerateAndMockery(t *testing.T) { | |
| 10 | - | b, err := os.ReadFile("../README.md") | |
| 12 | + | _, file, _, ok := runtime.Caller(0) | |
| 13 | + | if !ok { | |
| 14 | + | t.Fatal("runtime.Caller failed") | |
| 15 | + | } | |
| 16 | + | b, err := os.ReadFile(filepath.Join(filepath.Dir(file), "..", "README.md")) | |
| 11 | 17 | if err != nil { | |
| 12 | 18 | t.Fatalf("ReadFile returned error: %v", err) | |
| 13 | 19 | } | |
| @@ -2,12 +2,18 @@ package pipewire_test | |||||
| 2 | 2 | ||||
| 3 | import ( | 3 | import ( | ||
| 4 | "os" | 4 | "os" | ||
| 5 | + | "path/filepath" | |||
| 6 | + | "runtime" | |||
| 5 | "strings" | 7 | "strings" | ||
| 6 | "testing" | 8 | "testing" | ||
| 7 | ) | 9 | ) | ||
| 8 | 10 | ||||
| 9 | func TestReadmeMentionsGenerateAndMockery(t *testing.T) { | 11 | func TestReadmeMentionsGenerateAndMockery(t *testing.T) { | ||
| 10 | - | b, err := os.ReadFile("../README.md") | 12 | + | _, file, _, ok := runtime.Caller(0) |
| 13 | + | if !ok { | |||
| 14 | + | t.Fatal("runtime.Caller failed") | |||
| 15 | + | } | |||
| 16 | + | b, err := os.ReadFile(filepath.Join(filepath.Dir(file), "..", "README.md")) | |||
| 11 | if err != nil { | 17 | if err != nil { | ||
| 12 | t.Fatalf("ReadFile returned error: %v", err) | 18 | t.Fatalf("ReadFile returned error: %v", err) | ||
| 13 | } | 19 | } | ||
M pipewire/registry.go +0 -15
| @@ -2,8 +2,6 @@ package pipewire | |||
| 2 | 2 | ||
| 3 | 3 | import ( | |
| 4 | 4 | "unsafe" | |
| 5 | - | ||
| 6 | - | "github.com/bnema/purego-pipewire/internal/core" | |
| 7 | 5 | ) | |
| 8 | 6 | ||
| 9 | 7 | // Registry is the public interface for PipeWire registry operations. | |
| @@ -12,16 +10,3 @@ type Registry interface { | |||
| 12 | 10 | Destroy() | |
| 13 | 11 | Bind(name uint32, t string, version uint32) (unsafe.Pointer, error) | |
| 14 | 12 | } | |
| 15 | - | ||
| 16 | - | // registryWrapper wraps the internal core.Registry to implement the public Registry interface. | |
| 17 | - | type registryWrapper struct { | |
| 18 | - | inner *core.Registry | |
| 19 | - | } | |
| 20 | - | ||
| 21 | - | func (rw registryWrapper) Destroy() { | |
| 22 | - | rw.inner.Destroy() | |
| 23 | - | } | |
| 24 | - | ||
| 25 | - | func (rw registryWrapper) Bind(name uint32, t string, version uint32) (unsafe.Pointer, error) { | |
| 26 | - | return rw.inner.Bind(name, t, version) | |
| 27 | - | } | |
| @@ -2,8 +2,6 @@ package pipewire | |||||
| 2 | 2 | ||||
| 3 | import ( | 3 | import ( | ||
| 4 | "unsafe" | 4 | "unsafe" | ||
| 5 | - | ||||
| 6 | - | "github.com/bnema/purego-pipewire/internal/core" | |||
| 7 | ) | 5 | ) | ||
| 8 | 6 | ||||
| 9 | // Registry is the public interface for PipeWire registry operations. | 7 | // Registry is the public interface for PipeWire registry operations. | ||
| @@ -12,16 +10,3 @@ type Registry interface { | |||||
| 12 | Destroy() | 10 | Destroy() | ||
| 13 | Bind(name uint32, t string, version uint32) (unsafe.Pointer, error) | 11 | Bind(name uint32, t string, version uint32) (unsafe.Pointer, error) | ||
| 14 | } | 12 | } | ||
| 15 | - | ||||
| 16 | - | // registryWrapper wraps the internal core.Registry to implement the public Registry interface. | |||
| 17 | - | type registryWrapper struct { | |||
| 18 | - | inner *core.Registry | |||
| 19 | - | } | |||
| 20 | - | ||||
| 21 | - | func (rw registryWrapper) Destroy() { | |||
| 22 | - | rw.inner.Destroy() | |||
| 23 | - | } | |||
| 24 | - | ||||
| 25 | - | func (rw registryWrapper) Bind(name uint32, t string, version uint32) (unsafe.Pointer, error) { | |||
| 26 | - | return rw.inner.Bind(name, t, version) | |||
| 27 | - | } | |||
M pipewire/stream.go +0 -19
| @@ -2,8 +2,6 @@ package pipewire | |||
| 2 | 2 | ||
| 3 | 3 | import ( | |
| 4 | 4 | "unsafe" | |
| 5 | - | ||
| 6 | - | "github.com/bnema/purego-pipewire/internal/core" | |
| 7 | 5 | ) | |
| 8 | 6 | ||
| 9 | 7 | // Stream is the public interface for PipeWire stream operations. | |
| @@ -13,20 +11,3 @@ type Stream interface { | |||
| 13 | 11 | Connect(direction int, id uint32, flags uint32, params unsafe.Pointer) error | |
| 14 | 12 | Disconnect() | |
| 15 | 13 | } | |
| 16 | - | ||
| 17 | - | // streamWrapper wraps the internal core.Stream to implement the public Stream interface. | |
| 18 | - | type streamWrapper struct { | |
| 19 | - | inner *core.Stream | |
| 20 | - | } | |
| 21 | - | ||
| 22 | - | func (sw streamWrapper) Destroy() { | |
| 23 | - | sw.inner.Destroy() | |
| 24 | - | } | |
| 25 | - | ||
| 26 | - | func (sw streamWrapper) Connect(direction int, id uint32, flags uint32, params unsafe.Pointer) error { | |
| 27 | - | return sw.inner.Connect(direction, id, flags, params) | |
| 28 | - | } | |
| 29 | - | ||
| 30 | - | func (sw streamWrapper) Disconnect() { | |
| 31 | - | sw.inner.Disconnect() | |
| 32 | - | } | |
| @@ -2,8 +2,6 @@ package pipewire | |||||
| 2 | 2 | ||||
| 3 | import ( | 3 | import ( | ||
| 4 | "unsafe" | 4 | "unsafe" | ||
| 5 | - | ||||
| 6 | - | "github.com/bnema/purego-pipewire/internal/core" | |||
| 7 | ) | 5 | ) | ||
| 8 | 6 | ||||
| 9 | // Stream is the public interface for PipeWire stream operations. | 7 | // Stream is the public interface for PipeWire stream operations. | ||
| @@ -13,20 +11,3 @@ type Stream interface { | |||||
| 13 | Connect(direction int, id uint32, flags uint32, params unsafe.Pointer) error | 11 | Connect(direction int, id uint32, flags uint32, params unsafe.Pointer) error | ||
| 14 | Disconnect() | 12 | Disconnect() | ||
| 15 | } | 13 | } | ||
| 16 | - | ||||
| 17 | - | // streamWrapper wraps the internal core.Stream to implement the public Stream interface. | |||
| 18 | - | type streamWrapper struct { | |||
| 19 | - | inner *core.Stream | |||
| 20 | - | } | |||
| 21 | - | ||||
| 22 | - | func (sw streamWrapper) Destroy() { | |||
| 23 | - | sw.inner.Destroy() | |||
| 24 | - | } | |||
| 25 | - | ||||
| 26 | - | func (sw streamWrapper) Connect(direction int, id uint32, flags uint32, params unsafe.Pointer) error { | |||
| 27 | - | return sw.inner.Connect(direction, id, flags, params) | |||
| 28 | - | } | |||
| 29 | - | ||||
| 30 | - | func (sw streamWrapper) Disconnect() { | |||
| 31 | - | sw.inner.Disconnect() | |||
| 32 | - | } | |||