Replace var with anytype

This commit is contained in:
Sam Tebbs 2020-07-12 18:06:54 +01:00
parent f0add1917c
commit afcaf96e6e
9 changed files with 42 additions and 42 deletions

View file

@ -46,9 +46,9 @@ fn logCallback(context: void, str: []const u8) LoggingError!usize {
/// whether it is filtered.
/// IN comptime format: []const u8 - The message format. Uses the standard format specification
/// options.
/// IN args: var - A struct of the parameters for the format string.
/// IN args: anytype - A struct of the parameters for the format string.
///
pub fn log(comptime level: Level, comptime format: []const u8, args: var) void {
pub fn log(comptime level: Level, comptime format: []const u8, args: anytype) void {
fmt.format(OutStream{ .context = {} }, "[" ++ @tagName(level) ++ "] " ++ format, args) catch unreachable;
}
@ -58,9 +58,9 @@ pub fn log(comptime level: Level, comptime format: []const u8, args: var) void {
/// Arguments:
/// IN comptime format: []const u8 - The message format. Uses the standard format specification
/// options.
/// IN args: var - A struct of the parameters for the format string.
/// IN args: anytype - A struct of the parameters for the format string.
///
pub fn logInfo(comptime format: []const u8, args: var) void {
pub fn logInfo(comptime format: []const u8, args: anytype) void {
log(Level.INFO, format, args);
}
@ -70,9 +70,9 @@ pub fn logInfo(comptime format: []const u8, args: var) void {
/// Arguments:
/// IN comptime format: []const u8 - The message format. Uses the standard format specification
/// options.
/// IN args: var - A struct of the parameters for the format string.
/// IN args: anytype - A struct of the parameters for the format string.
///
pub fn logDebug(comptime format: []const u8, args: var) void {
pub fn logDebug(comptime format: []const u8, args: anytype) void {
log(Level.DEBUG, format, args);
}
@ -82,9 +82,9 @@ pub fn logDebug(comptime format: []const u8, args: var) void {
/// Arguments:
/// IN comptime format: []const u8 - The message format. Uses the standard format specification
/// options.
/// IN args: var - A struct of the parameters for the format string.
/// IN args: anytype - A struct of the parameters for the format string.
///
pub fn logWarning(comptime format: []const u8, args: var) void {
pub fn logWarning(comptime format: []const u8, args: anytype) void {
log(Level.WARNING, format, args);
}
@ -94,9 +94,9 @@ pub fn logWarning(comptime format: []const u8, args: var) void {
/// Arguments:
/// IN comptime format: []const u8 - The message format. Uses the standard format specification
/// options.
/// IN args: var - A struct of the parameters for the format string.
/// IN args: anytype - A struct of the parameters for the format string.
///
pub fn logError(comptime format: []const u8, args: var) void {
pub fn logError(comptime format: []const u8, args: anytype) void {
log(Level.ERROR, format, args);
}

View file

@ -65,12 +65,12 @@ pub var ADDR_OFFSET: usize = undefined;
/// Convert a virtual address to its physical counterpart by subtracting the kernel virtual offset from the virtual address.
///
/// Arguments:
/// IN virt: var - The virtual address to covert. Either an integer or pointer.
/// IN virt: anytype - The virtual address to covert. Either an integer or pointer.
///
/// Return: @TypeOf(virt)
/// The physical address.
///
pub fn virtToPhys(virt: var) @TypeOf(virt) {
pub fn virtToPhys(virt: anytype) @TypeOf(virt) {
const T = @TypeOf(virt);
return switch (@typeInfo(T)) {
.Pointer => @intToPtr(T, @ptrToInt(virt) - ADDR_OFFSET),
@ -83,12 +83,12 @@ pub fn virtToPhys(virt: var) @TypeOf(virt) {
/// Convert a physical address to its virtual counterpart by adding the kernel virtual offset to the physical address.
///
/// Arguments:
/// IN phys: var - The physical address to covert. Either an integer or pointer.
/// IN phys: anytype - The physical address to covert. Either an integer or pointer.
///
/// Return: @TypeOf(virt)
/// The virtual address.
///
pub fn physToVirt(phys: var) @TypeOf(phys) {
pub fn physToVirt(phys: anytype) @TypeOf(phys) {
const T = @TypeOf(phys);
return switch (@typeInfo(T)) {
.Pointer => @intToPtr(T, @ptrToInt(phys) + ADDR_OFFSET),

View file

@ -105,7 +105,7 @@ fn logTraceAddress(addr: usize) void {
log.logError("{x}: {}\n", .{ addr, str });
}
pub fn panic(trace: ?*builtin.StackTrace, comptime format: []const u8, args: var) noreturn {
pub fn panic(trace: ?*builtin.StackTrace, comptime format: []const u8, args: anytype) noreturn {
@setCold(true);
log.logError("Kernel panic: " ++ format ++ "\n", args);
if (trace) |trc| {

View file

@ -47,9 +47,9 @@ fn printCallback(ctx: void, str: []const u8) !usize {
///
/// Arguments:
/// IN comptime format: []const u8 - The format string to print
/// IN args: var - The arguments to be used in the formatted string
/// IN args: anytype - The arguments to be used in the formatted string
///
pub fn print(comptime format: []const u8, args: var) void {
pub fn print(comptime format: []const u8, args: anytype) void {
// Printing can't error because of the scrolling, if it does, we have a big problem
fmt.format(OutStream{ .context = {} }, format, args) catch |e| {
log.logError("TTY: Error printing. Error: {}\n", .{e});

View file

@ -417,7 +417,7 @@ const TestFS = struct {
self.allocator.destroy(self.fs);
}
fn getTreeNode(test_fs: *Self, node: var) Allocator.Error!?*TreeNode {
fn getTreeNode(test_fs: *Self, node: anytype) Allocator.Error!?*TreeNode {
switch (@TypeOf(node)) {
*const Node, *const FileNode, *const DirNode => {},
else => @compileError("Node is of type " ++ @typeName(@TypeOf(node)) ++ ". Only *const Node, *const FileNode and *const DirNode are supported"),