<commit_before>// Host descriptor data structures.

package embd

import (
	"errors"
	"fmt"
)

// Descriptor represents a host descriptor.
type Descriptor struct {
	GPIODriver func() GPIODriver
	I2CDriver  func() I2CDriver
	LEDDriver  func() LEDDriver
}

// The Describer type is a Descriptor provider.
type Describer func(rev int) *Descriptor

// Describers is a global list of registered host Describers.
var describers = make(map[Host]Describer)

// Register makes a host describer available by the provided host key.
// If Register is called twice with the same host or if describer is nil,
// it panics.
func Register(host Host, describer Describer) {
	if describer == nil {
		panic("embd: describer is nil")
	}
	if _, dup := describers[host]; dup {
		panic("embd: describer already registered")
	}
	describers[host] = describer
}

var hostOverride Host
var hostRevOverride int
var hostOverriden bool

// SetHost overrides the host and revision no.
func SetHost(host Host, rev int) {
	hostOverride = host
	hostRevOverride = rev

	hostOverriden = true
}<commit_msg>hal: log when host is registered<commit_after>// Host descriptor data structures.

package embd

import (
	"errors"
	"fmt"

	"github.com/golang/glog"
)

// Descriptor represents a host descriptor.
type Descriptor struct {
	GPIODriver func() GPIODriver
	I2CDriver  func() I2CDriver
	LEDDriver  func() LEDDriver
}

// The Describer type is a Descriptor provider.
type Describer func(rev int) *Descriptor

// Describers is a global list of registered host Describers.
var describers = make(map[Host]Describer)

// Register makes a host describer available by the provided host key.
// If Register is called twice with the same host or if describer is nil,
// it panics.
func Register(host Host, describer Describer) {
	if describer == nil {
		panic("embd: describer is nil")
	}
	if _, dup := describers[host]; dup {
		panic("embd: describer already registered")
	}
	describers[host] = describer

	glog.V(1).Infof("embd: host %v is registered", host)
}

var hostOverride Host
var hostRevOverride int
var hostOverriden bool

// SetHost overrides the host and revision no.
func SetHost(host Host, rev int) {
	hostOverride = host
	hostRevOverride = rev

	hostOverriden = true
}
{'fraction_non_alphanumeric': 0.08530594015185351, 'fraction_numerical': 0.0022331397945511387, 'mean_word_length': 4.209302325581396, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7505437', 'n_tokens_mistral': 728, 'n_tokens_neox': 698, 'n_words': 266}