xpc

package
v0.7.0-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package xpc provides Go bindings for the XPC framework.

High-level Go bindings for the XPC framework.

The public API is centered on Listener, Session, and ReceivedMessage.

Notes

  • Dictionary-first messaging is always available: CallDictionary and NotifyDictionary send a Dictionary, and ReceivedMessage.Dictionary returns one.
  • Typed payloads are supported through Call, Notify, Decode, Marshaler, and Unmarshaler.
  • Swift members without a safe public C path are omitted and recorded in xpc.omissions.gen.go.

Code generated from Apple documentation. DO NOT EDIT.

Index

Constants

View Source
const (
	ConnectionMachServiceListener   uint64 = 1 << 0
	ConnectionMachServicePrivileged uint64 = 1 << 1
)

ConnectionMachServiceListener and ConnectionMachServicePrivileged are the flags accepted by NewMachServiceConnection.

Variables

This section is empty.

Functions

func ActivateSocket

func ActivateSocket(name string) ([]int, error)

ActivateSocket returns the file descriptors launchd activated for name. The caller owns and must close every returned descriptor. Each socket name may be activated only once by a launchd-managed process.

func CopyValue

func CopyValue(value any) (any, error)

CopyValue makes an independent XPC copy of value and decodes it back into a Go value. It is useful when the XPC copy semantics matter; ordinary Go values should normally be copied with ordinary Go code instead.

func CurrentDate

func CurrentDate() (time.Time, error)

CurrentDate returns XPC's current date, decoded as a time.Time.

func Equal

func Equal(a, b any) (bool, error)

Equal reports whether two XPC values compare equal. File descriptor objects compare by pointer identity, so separate objects for the same descriptor do not compare equal.

func Hash

func Hash(value any) (uintptr, error)

Hash returns XPC's hash for value. It is intended for equality-compatible lookup, not as a stable value across processes or releases.

func NewSharedMemory

func NewSharedMemory(size int) (*SharedMemory, *Mapping, error)

NewSharedMemory allocates size bytes of shared memory and boxes it for sending. It returns the region boxed and the creator's own mapping of it, which is where the caller writes the contents before sending.

The region is allocated with mmap and MAP_SHARED because that is what xpc_shmem_create requires. Memory from Go, or from malloc, is owned by an allocator rather than by the caller, and boxing it is API misuse that traps in the sending process with no indication of the cause.

Closing the SharedMemory does not unmap the returned Mapping, and closing the Mapping does not invalidate the SharedMemory: XPC holds its own reference to the underlying region.

func RegisterActivity

func RegisterActivity(identifier string, criteria Dictionary, handler ActivityHandler) error

RegisterActivity registers handler under identifier with dictionary criteria.

func SetEventStreamHandler

func SetEventStreamHandler(stream string, queue dispatch.Queue, handler EventHandler) error

SetEventStreamHandler installs handler for stream. A process may install at most one handler for a stream; calling the native API twice for the same stream is undefined. The handler is retained for the process lifetime.

func Transaction

func Transaction() (func(), error)

Transaction begins an XPC service transaction and returns its matching end function. The end function is safe to call more than once. Leaving a transaction open keeps an XPC service alive indefinitely.

func UnregisterActivity

func UnregisterActivity(identifier string) error

UnregisterActivity removes identifier's registration.

Types

type Activity

type Activity struct {
	// contains filtered or unexported fields
}

Activity is a scheduled XPC activity. Values delivered to a handler retain their raw object, so they remain valid after the handler returns; Close releases that reference.

func (*Activity) Close

func (a *Activity) Close() error

func (*Activity) Criteria

func (a *Activity) Criteria() (Dictionary, error)

Criteria returns a copy of a's criteria dictionary.

func (*Activity) ShouldDefer

func (a *Activity) ShouldDefer() (bool, error)

ShouldDefer reports whether the scheduler requests deferred work.

type ActivityHandler

type ActivityHandler func(*Activity)

ActivityHandler receives an owned activity handle.

type CancellationHandler

type CancellationHandler func(RichError)

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

Connection is a peer on XPC's classic connection API.

func NewAnonymousConnection

func NewAnonymousConnection(queue dispatch.Queue, handler ConnectionHandler) (*Connection, error)

NewAnonymousConnection creates an inactive anonymous listener connection. handler is installed before the connection can be activated.

func NewConnectionFromEndpoint

func NewConnectionFromEndpoint(endpoint Endpoint, handler ConnectionHandler) (*Connection, error)

NewConnectionFromEndpoint creates an inactive peer connection to endpoint. handler is installed before the connection can be activated.

func NewMachServiceConnection

func NewMachServiceConnection(name string, queue dispatch.Queue, flags uint64, handler ConnectionHandler) (*Connection, error)

NewMachServiceConnection creates an inactive connection to name.

func (*Connection) Activate

func (c *Connection) Activate() error

Activate activates c. A connection is created suspended and must have an event handler before activation.

func (*Connection) AuditSessionID

func (c *Connection) AuditSessionID() (int32, error)

AuditSessionID returns the peer audit-session ID.

func (*Connection) CallDictionary

func (c *Connection) CallDictionary(ctx context.Context, msg Dictionary) (Dictionary, error)

CallDictionary sends msg and waits for its reply. ctx is caller-side only: classic XPC has no per-message deadline.

func (*Connection) Cancel

func (c *Connection) Cancel() error

Cancel terminates c. It is safe to call more than once.

func (*Connection) EGID

func (c *Connection) EGID() (uint32, error)

EGID returns the peer effective group ID. See PID's authorization warning.

func (*Connection) EUID

func (c *Connection) EUID() (uint32, error)

EUID returns the peer effective user ID. See PID's authorization warning.

func (*Connection) Endpoint

func (c *Connection) Endpoint() (Endpoint, error)

Endpoint returns an endpoint that can create peer connections to c.

func (*Connection) InvalidationReason

func (c *Connection) InvalidationReason() (string, error)

InvalidationReason returns XPC's owned invalidation description.

func (*Connection) Name

func (c *Connection) Name() (string, error)

Name returns c's borrowed service name.

func (*Connection) PID

func (c *Connection) PID() (int32, error)

PID returns the peer process ID. PID, EUID, and EGID are racy for authorization because a peer can exec between check and use; use PeerRequirement for authorization decisions.

func (*Connection) Resume

func (c *Connection) Resume() error

Resume decrements c's suspension count.

func (*Connection) SendDictionary

func (c *Connection) SendDictionary(msg Dictionary) error

SendDictionary queues msg without waiting for delivery or a reply.

func (*Connection) SetPeerCodeSigningRequirement

func (c *Connection) SetPeerCodeSigningRequirement(requirement string) error

SetPeerCodeSigningRequirement installs requirement before c is activated.

func (*Connection) SetPeerEntitlementExistsRequirement

func (c *Connection) SetPeerEntitlementExistsRequirement(entitlement string) error

func (*Connection) SetPeerPlatformIdentityRequirement

func (c *Connection) SetPeerPlatformIdentityRequirement(identifier string) error

func (*Connection) SetPeerRequirement

func (c *Connection) SetPeerRequirement(req *PeerRequirement) error

SetPeerRequirement installs req before c is activated.

func (*Connection) SetPeerTeamIdentityRequirement

func (c *Connection) SetPeerTeamIdentityRequirement(identifier string) error

func (*Connection) SetTargetQueue

func (c *Connection) SetTargetQueue(queue dispatch.Queue) error

SetTargetQueue replaces the target queue before c is activated.

func (*Connection) Suspend

func (c *Connection) Suspend() error

Suspend increments c's suspension count. Resume decrements it.

type ConnectionHandler

type ConnectionHandler func(Dictionary)

ConnectionHandler receives a message or an XPC error dictionary from a classic connection. It runs on the connection's target queue.

type Dictionary

type Dictionary map[string]any

type Endpoint

type Endpoint struct {
	// contains filtered or unexported fields
}

Endpoint is an XPC endpoint handle. Values returned by Connection.Endpoint or decoded from a message own a reference and must be closed. Copies share that ownership, so closing one copy invalidates all of them. EndpointFromHandle creates a borrowed wrapper and does not release the caller's reference.

func EndpointFromHandle

func EndpointFromHandle(handle uintptr) Endpoint

EndpointFromHandle wraps a borrowed XPC endpoint handle. The caller retains ownership; the wrapper never releases it.

func (Endpoint) Close

func (e Endpoint) Close() error

Close releases an endpoint reference owned by e. It is safe to call on a borrowed, zero, or already closed Endpoint. Copies share the same reference and observe the closed state. Calls using an Endpoint must be synchronized with Close.

If xpc_release is unavailable, Close clears the handle and reports the error; the reference is then leaked because it cannot be released.

func (Endpoint) Handle

func (e Endpoint) Handle() uintptr

Handle returns the underlying XPC endpoint handle. It returns zero after Close; a borrowed Endpoint remains nonzero because Close does not own it.

type EventHandler

type EventHandler func(Dictionary)

EventHandler receives one event from an XPC event stream. The dictionary is valid for the duration of the call and is copied into Go values before the handler runs.

type FileDescriptor

type FileDescriptor struct {
	// contains filtered or unexported fields
}

FileDescriptor is a POSIX file descriptor carried in an XPC message.

It is a handle, not a descriptor number. XPC boxes a descriptor by duplicating it, and every read hands back a further duplicate, so there is no one descriptor for this value to be: xpc_fd_dup's contract is that repeated calls return equivalent but distinct descriptors. Dup performs that duplication and transfers ownership of the result to the caller.

Decoding retains the boxed object, so a FileDescriptor stays valid after the handler that received it returns. Close releases that reference.

func NewFileDescriptor

func NewFileDescriptor(fd int) (*FileDescriptor, error)

NewFileDescriptor boxes fd for sending.

xpc_fd_create duplicates the descriptor, so the caller keeps ownership of fd and may close it as soon as this returns.

func (*FileDescriptor) Close

func (f *FileDescriptor) Close() error

Close releases the reference to the boxed descriptor. Descriptors already handed out by Dup are unaffected; they remain the caller's to close.

It is safe to call twice. If xpc_release is unavailable the handle is cleared anyway, so Close stays idempotent, and the error is reported rather than swallowed.

func (*FileDescriptor) Dup

func (f *FileDescriptor) Dup() (int, error)

Dup returns a new descriptor equivalent to the boxed one, as though it had been created by dup(2). The caller is responsible for closing it.

Dup may be called more than once; each call yields a separate descriptor and each must be closed separately.

type IncomingDecision

type IncomingDecision struct {
	// contains filtered or unexported fields
}

type IncomingSessionRequest

type IncomingSessionRequest struct {
	// contains filtered or unexported fields
}

func IncomingSessionRequestFromHandle

func IncomingSessionRequestFromHandle(handle uintptr) IncomingSessionRequest

IncomingSessionRequestFromHandle wraps a borrowed XPC incoming-session peer handle. The caller retains ownership; the wrapper never releases it.

func (IncomingSessionRequest) Accept

func (IncomingSessionRequest) AcceptSession

func (r IncomingSessionRequest) AcceptSession(handler MessageHandler, onCancel CancellationHandler) (IncomingDecision, *Session)

func (IncomingSessionRequest) Handle

func (r IncomingSessionRequest) Handle() uintptr

Handle returns the underlying XPC incoming-session peer handle.

func (IncomingSessionRequest) Reject

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

func ListenerFromHandle

func ListenerFromHandle(handle uintptr) *Listener

ListenerFromHandle wraps a borrowed XPC listener handle. The caller retains ownership; the wrapper never releases it.

func NewAnonymousListener

func NewAnonymousListener(opts ListenerOptions, incoming func(IncomingSessionRequest) IncomingDecision) *Listener

func NewServiceListener

func NewServiceListener(service string, opts ListenerOptions, incoming func(IncomingSessionRequest) IncomingDecision) (*Listener, error)

func (*Listener) Activate

func (l *Listener) Activate() error

func (*Listener) Cancel

func (l *Listener) Cancel()

func (*Listener) Handle

func (l *Listener) Handle() uintptr

Handle returns the underlying XPC listener handle.

func (*Listener) SetPeerCodeSigningRequirement

func (l *Listener) SetPeerCodeSigningRequirement(requirement string) error

SetPeerCodeSigningRequirement installs requirement while the listener is inactive. XPC retains its own copy of the string. The requirement may be installed only once; native XPC treats a repeated installation as misuse.

func (*Listener) String

func (l *Listener) String() string

String returns XPC's description of the listener. It is intended for diagnostics; an unavailable or uninitialized listener is described without calling into XPC.

type ListenerOptions

type ListenerOptions struct {
	Inactive bool
	// ForceMach and ForceXPCService tell the runtime which kind of listener
	// this is when the name alone does not determine it. A Mach service
	// listener needs ForceMach and a MachServices entry in the job's
	// launchd.plist.
	ForceMach       bool
	ForceXPCService bool
	Requirement     *PeerRequirement
	// TargetQueue is the dispatch queue session events are submitted onto.
	// The zero Queue means no target queue, which libdispatch treats as its
	// default target queue. Dispatch queues are process-lifetime objects
	// (the dispatch package never releases one), which is what makes storing
	// one here sound.
	TargetQueue dispatch.Queue
}

type Mapping

type Mapping struct {
	// Bytes is the mapped region. Its length is a whole number of pages.
	Bytes []byte
	// contains filtered or unexported fields
}

Mapping is a shared memory region mapped into this process.

Bytes aliases the mapping directly: it is not Go memory, writes through it are visible to every other process holding the region, and it must not be used after Close.

func (*Mapping) Close

func (m *Mapping) Close() error

Close unmaps the region. It is safe to call twice.

type Marshaler

type Marshaler interface {
	MarshalXPC() (Dictionary, error)
}

type MessageHandler

type MessageHandler func(ReceivedMessage) (any, error)

MessageHandler answers one incoming message. The returned value is encoded with the package wire format and sent as the reply. A non-nil error replies with Dictionary{"error": err.Error()}. Returning (nil, nil) declines to reply at all; to reply with an empty body, return Dictionary{}.

Exactly one reply is sent per invocation, by the runtime, after the handler returns. There is no way to reply twice, and no way to reply late.

type PeerRequirement

type PeerRequirement struct {
	// contains filtered or unexported fields
}

func NewEntitlementExistsRequirement

func NewEntitlementExistsRequirement(entitlement string) (*PeerRequirement, error)

NewEntitlementExistsRequirement returns a requirement that the peer has the given entitlement. An empty entitlement is rejected.

func NewEntitlementMatchesRequirement

func NewEntitlementMatchesRequirement(entitlement string, value any) (*PeerRequirement, error)

NewEntitlementMatchesRequirement returns a requirement that the peer has the given entitlement with a matching value. The value must be a bool, a string, or a signed integer that int64 represents exactly; Apple accepts exactly XPC_TYPE_BOOL, XPC_TYPE_STRING, and XPC_TYPE_INT64 for this call, so the general codec's wider surface is deliberately not used. Anything else is rejected with an error naming the value's type.

func NewLightweightCodeRequirement

func NewLightweightCodeRequirement(lwcr Dictionary) (*PeerRequirement, error)

NewLightweightCodeRequirement returns a requirement that the peer satisfy the given lightweight code requirement dictionary. A nil lwcr is rejected. The temporary object built from the dictionary is released once the constructor returns.

func NewPlatformBinaryRequirement

func NewPlatformBinaryRequirement() (*PeerRequirement, error)

NewPlatformBinaryRequirement returns a requirement that the peer be a platform binary. The signing identifier is not constrained further.

func NewPlatformBinarySignedAsRequirement

func NewPlatformBinarySignedAsRequirement(signingIdentifier string) (*PeerRequirement, error)

NewPlatformBinarySignedAsRequirement returns a requirement that the peer be a platform binary signed with the given signing identifier. An empty signingIdentifier is rejected: the header's meaningful NULL case is expressed by NewPlatformBinaryRequirement, and an empty C string is not NULL.

func NewSameTeamRequirement

func NewSameTeamRequirement() (*PeerRequirement, error)

NewSameTeamRequirement returns a requirement that the peer be signed with the same team identifier as the current process. The signing identifier is not constrained further.

func NewSameTeamSignedAsRequirement

func NewSameTeamSignedAsRequirement(signingIdentifier string) (*PeerRequirement, error)

NewSameTeamSignedAsRequirement returns a requirement that the peer be signed with the same team identifier as the current process and with the given signing identifier. An empty signingIdentifier is rejected: the header's meaningful NULL case is expressed by NewSameTeamRequirement, and an empty C string is not NULL.

func PeerRequirementFromHandle

func PeerRequirementFromHandle(handle uintptr) *PeerRequirement

PeerRequirementFromHandle is the deliberate exception to the borrowed-handle rule: it retains a nonzero handle and returns an owned reference that the caller must Close, exactly as if it had been built by one of the constructors. A zero handle returns nil. Supplying a handle the caller does not own, or one already released, is undefined behaviour at the C level.

func (*PeerRequirement) Close

func (r *PeerRequirement) Close() error

Close releases the requirement's reference. It is safe to call twice: the first call releases, and a second call (or a call on an already-closed requirement) returns nil. The requirement must not be used after Close.

If xpc_release is unavailable Close cannot release the reference. It clears the handle anyway, so Close stays idempotent, and returns the availability error; the underlying reference is then leaked and there is no way to recover it. This is the only outcome that leaks, and it is reported rather than swallowed.

func (*PeerRequirement) Handle

func (r *PeerRequirement) Handle() uintptr

Handle returns the underlying XPC peer requirement handle. The handle is borrowed: it is valid only until Close and reads as zero afterward.

type ReceivedMessage

type ReceivedMessage struct {
	// contains filtered or unexported fields
}

func ReceivedMessageFromHandle

func ReceivedMessageFromHandle(handle uintptr) ReceivedMessage

ReceivedMessageFromHandle wraps a borrowed XPC message handle. The caller retains ownership; the wrapper never releases it.

func (ReceivedMessage) Decode

func (m ReceivedMessage) Decode(dst any) error

func (ReceivedMessage) Dictionary

func (m ReceivedMessage) Dictionary() Dictionary

Dictionary returns the message body. The returned map is a shallow copy, so the caller may modify its top-level keys.

A message delivered by this package (a reply from CallDictionary, or the argument to a MessageHandler) decodes its raw object at most once, however many times Dictionary is called: each decode costs a permanently registered callback block, so repeated calls would otherwise consume a bounded process resource. A message wrapped with ReceivedMessageFromHandle has no such cache and decodes on every call, because its handle belongs to the caller.

func (ReceivedMessage) Handle

func (m ReceivedMessage) Handle() uintptr

Handle returns the underlying XPC message handle.

func (ReceivedMessage) SenderSatisfies

func (m ReceivedMessage) SenderSatisfies(req *PeerRequirement) bool

type RichError

type RichError struct {
	// contains filtered or unexported fields
}

func RichErrorFromHandle

func RichErrorFromHandle(handle uintptr) RichError

RichErrorFromHandle wraps a borrowed XPC rich error handle. The caller retains ownership; the wrapper never releases it.

func (RichError) CanRetry

func (e RichError) CanRetry() bool

func (RichError) Error

func (e RichError) Error() string

func (RichError) Handle

func (e RichError) Handle() uintptr

Handle returns the underlying XPC rich error handle.

func (RichError) Unwrap

func (e RichError) Unwrap() error

type Session

type Session struct {
	// contains filtered or unexported fields
}

func DialMachService

func DialMachService(name string, opts SessionOptions) (*Session, error)

func DialXPCService

func DialXPCService(name string, opts SessionOptions) (*Session, error)

func SessionFromHandle

func SessionFromHandle(handle uintptr) *Session

SessionFromHandle wraps a borrowed XPC session handle. The caller retains ownership; the wrapper never releases it. A session obtained this way has an unknowable lifecycle, so the inactive-only setters refuse it.

func (*Session) Activate

func (s *Session) Activate() error

func (*Session) Call

func (s *Session) Call(ctx context.Context, msg any) (ReceivedMessage, error)

Call encodes msg with the package wire format, sends it, and waits for the peer's reply. See CallDictionary for what ctx does and does not do.

func (*Session) CallDictionary

func (s *Session) CallDictionary(ctx context.Context, msg Dictionary) (ReceivedMessage, error)

CallDictionary sends msg and waits for the peer's reply.

libxpc has no per-message timeout and no per-message cancellation: none of the xpc_session_send_message* entry points takes a deadline, and xpc_session_cancel tears down the whole session rather than one call. ctx is therefore honoured on the caller's side only. If ctx ends first, CallDictionary returns ctx.Err(), but the peer keeps running the request and the pending reply context stays alive in libxpc until the reply arrives or the session is cancelled: a cancelled call costs one leaked reply slot.

If ctx cannot end (ctx.Done() == nil, as for context.Background), CallDictionary uses the cheaper blocking C send.

func (*Session) Cancel

func (s *Session) Cancel()

Cancel cancels the session. Any in-flight message fails and the cancel handler runs. Cancel is idempotent and safe on a nil or already-cancelled session.

There is no reason string: xpc_session_cancel takes only the session, so a reason parameter would be accepted and discarded. Compare IncomingSessionRequest.Reject, which does carry a reason to the peer.

func (*Session) Handle

func (s *Session) Handle() uintptr

Handle returns the underlying XPC session handle.

func (*Session) Notify

func (s *Session) Notify(msg any) error

Notify encodes msg with the package wire format and sends it without waiting for a reply. Delivery is not confirmed.

func (*Session) NotifyDictionary

func (s *Session) NotifyDictionary(msg Dictionary) error

NotifyDictionary sends msg without waiting for a reply. It returns when the message has been handed to the transport; delivery is not confirmed.

func (*Session) SetCancellationHandler

func (s *Session) SetCancellationHandler(handler CancellationHandler) error

func (*Session) SetIncomingMessageHandler

func (s *Session) SetIncomingMessageHandler(handler MessageHandler) error

func (*Session) SetPeerCodeSigningRequirement

func (s *Session) SetPeerCodeSigningRequirement(requirement string) error

SetPeerCodeSigningRequirement installs requirement while the session is inactive. XPC retains its own copy of the string. The requirement may be installed only once; native XPC treats a repeated installation as misuse.

func (*Session) SetPeerRequirement

func (s *Session) SetPeerRequirement(req *PeerRequirement) error

SetPeerRequirement installs a peer requirement on the session. The requirement must be installed while the session is inactive and at most once per session; installing on an active session, on a session created from a raw handle whose lifecycle is unknowable, or a second time is API misuse that traps the process in native code, so each is refused here before native code runs. The session does not retain the requirement beyond this call: XPC retains it on successful installation, so the caller may Close their reference immediately afterward.

func (*Session) SetTargetQueue

func (s *Session) SetTargetQueue(queue dispatch.Queue) error

SetTargetQueue replaces the session's target queue. It may be called more than once while the session is inactive; a zero queue restores libdispatch's default target queue. It refuses an active session and a handle-derived session before calling native code, both of which are API misuse.

func (*Session) String

func (s *Session) String() string

String returns XPC's description of the session. It is intended for diagnostics; an unavailable or uninitialized session is described without calling into XPC.

type SessionOptions

type SessionOptions struct {
	Inactive    bool
	Privileged  bool
	Requirement *PeerRequirement
	// TargetQueue is the dispatch queue session events are submitted onto.
	// The zero Queue means no target queue, which libdispatch treats as its
	// default target queue. Dispatch queues are process-lifetime objects
	// (the dispatch package never releases one), which is what makes storing
	// one here sound.
	TargetQueue dispatch.Queue
}

type SharedMemory

type SharedMemory struct {
	// contains filtered or unexported fields
}

SharedMemory is a shared memory region carried in an XPC message.

Like FileDescriptor it is a handle: the region is not part of this process's address space until Map places it there, and each Map is a separate mapping that must be closed separately.

Decoding retains the boxed object, so a SharedMemory stays valid after the handler that received it returns. Close releases that reference; it does not unmap anything Map returned.

func (*SharedMemory) Close

func (s *SharedMemory) Close() error

Close releases the reference to the boxed region. Mappings already made by Map are unaffected; they remain the caller's to close.

func (*SharedMemory) Map

func (s *SharedMemory) Map() (*Mapping, error)

Map places the region in this process's address space.

The mapping is always a whole number of pages, so len(Mapping.Bytes) can exceed the size the sender asked for. The caller must close the Mapping.

type UUID

type UUID [16]byte

UUID is an xpc_uuid_t, the 16 bytes exactly as they travel on the wire. It is a distinct type rather than [16]byte so that encoding can tell a UUID from a 16-element byte array, which XPC carries as data.

type Unmarshaler

type Unmarshaler interface {
	UnmarshalXPC(Dictionary) error
}

type Unsupported

type Unsupported struct {
	// Type is the XPC type name, as xpc_type_get_name reports it,
	// for example "connection" or "activity".
	Type string

	// Description is xpc_copy_description output. It is a debugging aid
	// and nothing more.
	Description string
}

Unsupported is an XPC value this package has no Go representation for.

It exists so that decoding is never silently lossy. Rather than return something that looks like ordinary data, decoding yields an Unsupported carrying the XPC type name and the description XPC itself prints.

Encoding an Unsupported is an error: it records what arrived, and cannot reconstitute it.

type Xpc_object_t

type Xpc_object_t = objectivec.Object

Xpc_object_t is the Go spelling of the C xpc_object_t handle.

The cross-framework registry attributes xpc_object_t to this package, so every other framework resolves the C type to xpc.Xpc_object_t. Until this declaration existed that reference dangled, and each consumer silently degraded to unsafe.Pointer -- foundation.NSXPCCoder's encode and decode methods among them. The degradation left no trace to search for: the emitted output contained no occurrence of the missing name, so the only evidence was the absence of a symbol nobody knew to look for.

It is an objectivec.Object rather than an opaque pointer because XPC objects are Objective-C objects under the bridge. That keeps the handle typed for callers, and it keeps a non-Go address out of a slot the Go garbage collector would scan.

type Xpc_type_t

type Xpc_type_t uintptr

Xpc_type_t is the Go spelling of the C xpc_type_t handle, which identifies an XPC object's type rather than holding one.

It is a uintptr rather than an objectivec.Object or an unsafe.Pointer because the value is an opaque descriptor and not a Go pointer: uintptr is the one spelling of the three that the Go garbage collector does not scan.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL