zig/lib/std/os/uefi/protocol/hii_database.zig
Andrew Kelley a31748b29e std.os.uefi: reorganize namespaces
This is a breaking change.

This commit applies the following rules to std.os.uefi:
* avoid redundant names in the namespace such as "protocol.FooProtocol"
* don't initialize struct field to undefined. do that at the
  initialization site if you want that, or create a named constant that
  sets all the fields to undefined.
* avoid the word "data", "info", "context", "state", "details", or
  "config" in the type name, especially if a word from that category is
  already in the type name.
* embrace tree structure

After following these rules, `usingnamespace` disappeared naturally.
This commit eliminates 26/53 (49%) instances of `usingnamespace` in the
standard library. All these uses were due to not understanding how
to properly use namespaces.

I did not test this commit. The standard library UEFI code is
experimental and pull requests have been accepted with minimal vetting.
Users of std.os.uefi will need to submit follow-up pull requests to fix
up whatever regressions this commit introduces, this time without
abusing namespaces (pun intended).
2023-08-24 22:38:47 -07:00

51 lines
2.3 KiB
Zig

const std = @import("std");
const uefi = std.os.uefi;
const Guid = uefi.Guid;
const Status = uefi.Status;
const hii = uefi.hii;
const cc = uefi.cc;
/// Database manager for HII-related data structures.
pub const HIIDatabase = extern struct {
_new_package_list: Status, // TODO
_remove_package_list: *const fn (*const HIIDatabase, hii.Handle) callconv(cc) Status,
_update_package_list: *const fn (*const HIIDatabase, hii.Handle, *const hii.PackageList) callconv(cc) Status,
_list_package_lists: *const fn (*const HIIDatabase, u8, ?*const Guid, *usize, [*]hii.Handle) callconv(cc) Status,
_export_package_lists: *const fn (*const HIIDatabase, ?hii.Handle, *usize, *hii.PackageList) callconv(cc) Status,
_register_package_notify: Status, // TODO
_unregister_package_notify: Status, // TODO
_find_keyboard_layouts: Status, // TODO
_get_keyboard_layout: Status, // TODO
_set_keyboard_layout: Status, // TODO
_get_package_list_handle: Status, // TODO
/// Removes a package list from the HII database.
pub fn removePackageList(self: *const HIIDatabase, handle: hii.Handle) Status {
return self._remove_package_list(self, handle);
}
/// Update a package list in the HII database.
pub fn updatePackageList(self: *const HIIDatabase, handle: hii.Handle, buffer: *const hii.PackageList) Status {
return self._update_package_list(self, handle, buffer);
}
/// Determines the handles that are currently active in the database.
pub fn listPackageLists(self: *const HIIDatabase, package_type: u8, package_guid: ?*const Guid, buffer_length: *usize, handles: [*]hii.Handle) Status {
return self._list_package_lists(self, package_type, package_guid, buffer_length, handles);
}
/// Exports the contents of one or all package lists in the HII database into a buffer.
pub fn exportPackageLists(self: *const HIIDatabase, handle: ?hii.Handle, buffer_size: *usize, buffer: *hii.PackageList) Status {
return self._export_package_lists(self, handle, buffer_size, buffer);
}
pub const guid align(8) = Guid{
.time_low = 0xef9fc172,
.time_mid = 0xa1b2,
.time_high_and_version = 0x4693,
.clock_seq_high_and_reserved = 0xb3,
.clock_seq_low = 0x27,
.node = [_]u8{ 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42 },
};
};