BAN: Make String and StringView header only
This allows linking with libc without having to link ban
This commit is contained in:
@@ -137,7 +137,6 @@ endif()
|
||||
set(BAN_SOURCES
|
||||
../BAN/BAN/Assert.cpp
|
||||
../BAN/BAN/New.cpp
|
||||
../BAN/BAN/String.cpp
|
||||
../BAN/BAN/StringView.cpp
|
||||
../BAN/BAN/Time.cpp
|
||||
)
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <BAN/StringView.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
enum class ErrorCode : uint32_t
|
||||
enum class ErrorCode
|
||||
{
|
||||
None,
|
||||
ACPI_NoRootSDT,
|
||||
@@ -31,6 +29,6 @@ namespace Kernel
|
||||
Count
|
||||
};
|
||||
|
||||
BAN::StringView error_string(ErrorCode);
|
||||
const char* error_string(ErrorCode);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,34 +1,38 @@
|
||||
#include <BAN/Assert.h>
|
||||
#include <kernel/Errors.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
static BAN::StringView s_error_strings[] {
|
||||
"No Error"sv,
|
||||
"ACPI could not find root SDT header"sv,
|
||||
"ACPI no such header"sv,
|
||||
static const char* s_error_strings[] {
|
||||
"No Error",
|
||||
"ACPI could not find root SDT header",
|
||||
"ACPI no such header",
|
||||
"ACPI root invalid",
|
||||
"Invalid ext2 filesystem"sv,
|
||||
"Ext2 filesystem corrupted"sv,
|
||||
"Ext2 filesystem out of inodes"sv,
|
||||
"Attempted to access outside of device boundaries"sv,
|
||||
"Device has invalid GPT header"sv,
|
||||
"Device does not support LBA addressing"sv,
|
||||
"Address mark not found"sv,
|
||||
"Track zero not found"sv,
|
||||
"Aborted command"sv,
|
||||
"Media change request"sv,
|
||||
"ID not found"sv,
|
||||
"Media changed"sv,
|
||||
"Uncorrectable data error"sv,
|
||||
"Bad Block detected"sv,
|
||||
"Unsupported ata device"sv,
|
||||
"Font file too small"sv,
|
||||
"Unsupported font format"sv,
|
||||
"Invalid ext2 filesystem",
|
||||
"Ext2 filesystem corrupted",
|
||||
"Ext2 filesystem out of inodes",
|
||||
"Attempted to access outside of device boundaries",
|
||||
"Device has invalid GPT header",
|
||||
"Device does not support LBA addressing",
|
||||
"Address mark not found",
|
||||
"Track zero not found",
|
||||
"Aborted command",
|
||||
"Media change request",
|
||||
"ID not found",
|
||||
"Media changed",
|
||||
"Uncorrectable data error",
|
||||
"Bad Block detected",
|
||||
"Unsupported ata device",
|
||||
"Font file too small",
|
||||
"Unsupported font format",
|
||||
};
|
||||
static_assert(sizeof(s_error_strings) / sizeof(*s_error_strings) == (size_t)ErrorCode::Count);
|
||||
|
||||
BAN::StringView error_string(ErrorCode error)
|
||||
const char* error_string(ErrorCode error)
|
||||
{
|
||||
ASSERT((uint32_t)error < (uint32_t)ErrorCode::Count);
|
||||
return s_error_strings[(uint32_t)error];
|
||||
|
||||
Reference in New Issue
Block a user