From 7c7d93d6d1b74b16268443dcbc79196ffa0e7c41 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Fri, 3 May 2024 12:46:09 -0400 Subject: [PATCH] Backend registering is platform-dependent --- application.go | 12 +++++++++--- internal/registry/doc.go | 2 ++ backend.go => internal/registry/registry_unix.go | 6 ++++-- 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 internal/registry/doc.go rename backend.go => internal/registry/registry_unix.go (57%) diff --git a/application.go b/application.go index f7d905a..7712f0c 100644 --- a/application.go +++ b/application.go @@ -1,7 +1,9 @@ package nasin +import "log" import "image" import "git.tebibyte.media/tomo/tomo" +import "git.tebibyte.media/tomo/nasin/internal/registry" // Application represents an application object. type Application interface { @@ -74,9 +76,13 @@ type ApplicationRole string; const ( RoleChecklist ApplicationRole = "Checklist" ) -// RunApplication is like Run, but runs an application. -func RunApplication (application Application) error { - return tomo.Run(application.Init) +// RunApplication is like tomo.Run, but runs an application. If something fails +// to initialize, an error is written to the standard logger. +func RunApplication (application Application) { + err := registry.Init() + if err != nil { log.Fatal("nasin: could not init registry:", err) } + err := tomo.Run(application.Init) + if err != nil { log.Fatal("nasin: could not run application:", err) } } // NewApplicationWindow creates a window for an application. It will diff --git a/internal/registry/doc.go b/internal/registry/doc.go new file mode 100644 index 0000000..97bff0c --- /dev/null +++ b/internal/registry/doc.go @@ -0,0 +1,2 @@ +// Package registry provides platform-dependent components at compile time. +package registry diff --git a/backend.go b/internal/registry/registry_unix.go similarity index 57% rename from backend.go rename to internal/registry/registry_unix.go index a7e97ae..b0a0bf6 100644 --- a/backend.go +++ b/internal/registry/registry_unix.go @@ -1,8 +1,10 @@ -package nasin +//go:build unix && (!darwin) +package registry import "git.tebibyte.media/tomo/x" import "git.tebibyte.media/tomo/tomo" -func init () { +func Init () error { tomo.Register(1, x.NewBackend) + return nil }