mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:27:35 +00:00
AK+Everywhere: Rename JsonObject::get() to ::get_deprecated()
This is a preparatory step to making `get()` return `ErrorOr`.
This commit is contained in:
parent
efe4329f9f
commit
1dd6b7f5b7
76 changed files with 671 additions and 671 deletions
|
@ -112,14 +112,14 @@ void MemoryStatsWidget::refresh()
|
|||
auto json_result = JsonValue::from_string(file_contents).release_value_but_fixme_should_propagate_errors();
|
||||
auto const& json = json_result.as_object();
|
||||
|
||||
u32 kmalloc_allocated = json.get("kmalloc_allocated"sv).to_u32();
|
||||
u32 kmalloc_available = json.get("kmalloc_available"sv).to_u32();
|
||||
u64 physical_allocated = json.get("physical_allocated"sv).to_u64();
|
||||
u64 physical_available = json.get("physical_available"sv).to_u64();
|
||||
u64 physical_committed = json.get("physical_committed"sv).to_u64();
|
||||
u64 physical_uncommitted = json.get("physical_uncommitted"sv).to_u64();
|
||||
u32 kmalloc_call_count = json.get("kmalloc_call_count"sv).to_u32();
|
||||
u32 kfree_call_count = json.get("kfree_call_count"sv).to_u32();
|
||||
u32 kmalloc_allocated = json.get_deprecated("kmalloc_allocated"sv).to_u32();
|
||||
u32 kmalloc_available = json.get_deprecated("kmalloc_available"sv).to_u32();
|
||||
u64 physical_allocated = json.get_deprecated("physical_allocated"sv).to_u64();
|
||||
u64 physical_available = json.get_deprecated("physical_available"sv).to_u64();
|
||||
u64 physical_committed = json.get_deprecated("physical_committed"sv).to_u64();
|
||||
u64 physical_uncommitted = json.get_deprecated("physical_uncommitted"sv).to_u64();
|
||||
u32 kmalloc_call_count = json.get_deprecated("kmalloc_call_count"sv).to_u32();
|
||||
u32 kfree_call_count = json.get_deprecated("kfree_call_count"sv).to_u32();
|
||||
|
||||
u64 kmalloc_bytes_total = kmalloc_allocated + kmalloc_available;
|
||||
u64 physical_pages_total = physical_allocated + physical_available;
|
||||
|
|
|
@ -47,25 +47,25 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
|
|||
Vector<GUI::JsonArrayModel::FieldSpec> net_adapters_fields;
|
||||
net_adapters_fields.empend("", Gfx::TextAlignment::CenterLeft,
|
||||
[this](JsonObject const& object) -> GUI::Variant {
|
||||
if (!object.get("link_up"sv).as_bool())
|
||||
if (!object.get_deprecated("link_up"sv).as_bool())
|
||||
return *m_network_link_down_bitmap;
|
||||
else
|
||||
return object.get("ipv4_address"sv).as_string_or(""sv).is_empty() ? *m_network_disconnected_bitmap : *m_network_connected_bitmap;
|
||||
return object.get_deprecated("ipv4_address"sv).as_string_or(""sv).is_empty() ? *m_network_disconnected_bitmap : *m_network_connected_bitmap;
|
||||
});
|
||||
net_adapters_fields.empend("name", "Name", Gfx::TextAlignment::CenterLeft);
|
||||
net_adapters_fields.empend("class_name", "Class", Gfx::TextAlignment::CenterLeft);
|
||||
net_adapters_fields.empend("mac_address", "MAC", Gfx::TextAlignment::CenterLeft);
|
||||
net_adapters_fields.empend("Link status", Gfx::TextAlignment::CenterLeft,
|
||||
[](JsonObject const& object) -> DeprecatedString {
|
||||
if (!object.get("link_up"sv).as_bool())
|
||||
if (!object.get_deprecated("link_up"sv).as_bool())
|
||||
return "Down";
|
||||
|
||||
return DeprecatedString::formatted("{} Mb/s {}-duplex", object.get("link_speed"sv).to_i32(),
|
||||
object.get("link_full_duplex"sv).as_bool() ? "full"sv : "half"sv);
|
||||
return DeprecatedString::formatted("{} Mb/s {}-duplex", object.get_deprecated("link_speed"sv).to_i32(),
|
||||
object.get_deprecated("link_full_duplex"sv).as_bool() ? "full"sv : "half"sv);
|
||||
});
|
||||
net_adapters_fields.empend("IPv4", Gfx::TextAlignment::CenterLeft,
|
||||
[](JsonObject const& object) -> DeprecatedString {
|
||||
return object.get("ipv4_address"sv).as_string_or(""sv);
|
||||
return object.get_deprecated("ipv4_address"sv).as_string_or(""sv);
|
||||
});
|
||||
net_adapters_fields.empend("packets_in", "Pkt In", Gfx::TextAlignment::CenterRight);
|
||||
net_adapters_fields.empend("packets_out", "Pkt Out", Gfx::TextAlignment::CenterRight);
|
||||
|
|
|
@ -27,19 +27,19 @@ ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget()
|
|||
pid_fds_fields.empend("offset", "Offset", Gfx::TextAlignment::CenterRight);
|
||||
pid_fds_fields.empend("absolute_path", "Path", Gfx::TextAlignment::CenterLeft);
|
||||
pid_fds_fields.empend("Access", Gfx::TextAlignment::CenterLeft, [](auto& object) {
|
||||
return object.get("seekable"sv).to_bool() ? "Seekable" : "Sequential";
|
||||
return object.get_deprecated("seekable"sv).to_bool() ? "Seekable" : "Sequential";
|
||||
});
|
||||
pid_fds_fields.empend("Blocking", Gfx::TextAlignment::CenterLeft, [](auto& object) {
|
||||
return object.get("blocking"sv).to_bool() ? "Blocking" : "Nonblocking";
|
||||
return object.get_deprecated("blocking"sv).to_bool() ? "Blocking" : "Nonblocking";
|
||||
});
|
||||
pid_fds_fields.empend("On exec", Gfx::TextAlignment::CenterLeft, [](auto& object) {
|
||||
return object.get("cloexec"sv).to_bool() ? "Close" : "Keep";
|
||||
return object.get_deprecated("cloexec"sv).to_bool() ? "Close" : "Keep";
|
||||
});
|
||||
pid_fds_fields.empend("Can read", Gfx::TextAlignment::CenterLeft, [](auto& object) {
|
||||
return object.get("can_read"sv).to_bool() ? "Yes" : "No";
|
||||
return object.get_deprecated("can_read"sv).to_bool() ? "Yes" : "No";
|
||||
});
|
||||
pid_fds_fields.empend("Can write", Gfx::TextAlignment::CenterLeft, [](auto& object) {
|
||||
return object.get("can_write"sv).to_bool() ? "Yes" : "No";
|
||||
return object.get_deprecated("can_write"sv).to_bool() ? "Yes" : "No";
|
||||
});
|
||||
|
||||
m_model = GUI::JsonArrayModel::create({}, move(pid_fds_fields));
|
||||
|
|
|
@ -57,35 +57,35 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget()
|
|||
Vector<GUI::JsonArrayModel::FieldSpec> pid_vm_fields;
|
||||
pid_vm_fields.empend(
|
||||
"Address", Gfx::TextAlignment::CenterLeft,
|
||||
[](auto& object) { return DeprecatedString::formatted("{:p}", object.get("address"sv).to_u64()); },
|
||||
[](auto& object) { return object.get("address"sv).to_u64(); });
|
||||
[](auto& object) { return DeprecatedString::formatted("{:p}", object.get_deprecated("address"sv).to_u64()); },
|
||||
[](auto& object) { return object.get_deprecated("address"sv).to_u64(); });
|
||||
pid_vm_fields.empend("size", "Size", Gfx::TextAlignment::CenterRight);
|
||||
pid_vm_fields.empend("amount_resident", "Resident", Gfx::TextAlignment::CenterRight);
|
||||
pid_vm_fields.empend("amount_dirty", "Dirty", Gfx::TextAlignment::CenterRight);
|
||||
pid_vm_fields.empend("Access", Gfx::TextAlignment::CenterLeft, [](auto& object) {
|
||||
StringBuilder builder;
|
||||
if (object.get("readable"sv).to_bool())
|
||||
if (object.get_deprecated("readable"sv).to_bool())
|
||||
builder.append('R');
|
||||
if (object.get("writable"sv).to_bool())
|
||||
if (object.get_deprecated("writable"sv).to_bool())
|
||||
builder.append('W');
|
||||
if (object.get("executable"sv).to_bool())
|
||||
if (object.get_deprecated("executable"sv).to_bool())
|
||||
builder.append('X');
|
||||
if (object.get("shared"sv).to_bool())
|
||||
if (object.get_deprecated("shared"sv).to_bool())
|
||||
builder.append('S');
|
||||
if (object.get("syscall"sv).to_bool())
|
||||
if (object.get_deprecated("syscall"sv).to_bool())
|
||||
builder.append('C');
|
||||
if (object.get("stack"sv).to_bool())
|
||||
if (object.get_deprecated("stack"sv).to_bool())
|
||||
builder.append('T');
|
||||
return builder.to_deprecated_string();
|
||||
});
|
||||
pid_vm_fields.empend("VMObject type", Gfx::TextAlignment::CenterLeft, [](auto& object) {
|
||||
auto type = object.get("vmobject"sv).to_deprecated_string();
|
||||
auto type = object.get_deprecated("vmobject"sv).to_deprecated_string();
|
||||
if (type.ends_with("VMObject"sv))
|
||||
type = type.substring(0, type.length() - 8);
|
||||
return type;
|
||||
});
|
||||
pid_vm_fields.empend("Purgeable", Gfx::TextAlignment::CenterLeft, [](auto& object) {
|
||||
if (object.get("volatile"sv).to_bool())
|
||||
if (object.get_deprecated("volatile"sv).to_bool())
|
||||
return "Volatile";
|
||||
return "Non-volatile";
|
||||
});
|
||||
|
@ -98,7 +98,7 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget()
|
|||
return GUI::Variant(0);
|
||||
},
|
||||
[](JsonObject const& object) {
|
||||
auto pagemap = object.get("pagemap"sv).as_string_or({});
|
||||
auto pagemap = object.get_deprecated("pagemap"sv).as_string_or({});
|
||||
return pagemap;
|
||||
});
|
||||
pid_vm_fields.empend("cow_pages", "# CoW", Gfx::TextAlignment::CenterRight);
|
||||
|
|
|
@ -39,7 +39,7 @@ ProcessModel::ProcessModel()
|
|||
auto cpuinfo_array = json.value().as_array();
|
||||
cpuinfo_array.for_each([&](auto& value) {
|
||||
auto& cpu_object = value.as_object();
|
||||
auto cpu_id = cpu_object.get("processor"sv).as_u32();
|
||||
auto cpu_id = cpu_object.get_deprecated("processor"sv).as_u32();
|
||||
m_cpus.append(make<CpuInfo>(cpu_id));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -130,18 +130,18 @@ public:
|
|||
[](const JsonObject& object) {
|
||||
StringBuilder size_builder;
|
||||
size_builder.append(' ');
|
||||
size_builder.append(human_readable_size(object.get("total_block_count"sv).to_u64() * object.get("block_size"sv).to_u64()));
|
||||
size_builder.append(human_readable_size(object.get_deprecated("total_block_count"sv).to_u64() * object.get_deprecated("block_size"sv).to_u64()));
|
||||
size_builder.append(' ');
|
||||
return size_builder.to_deprecated_string();
|
||||
},
|
||||
[](const JsonObject& object) {
|
||||
return object.get("total_block_count"sv).to_u64() * object.get("block_size"sv).to_u64();
|
||||
return object.get_deprecated("total_block_count"sv).to_u64() * object.get_deprecated("block_size"sv).to_u64();
|
||||
},
|
||||
[](const JsonObject& object) {
|
||||
auto total_blocks = object.get("total_block_count"sv).to_u64();
|
||||
auto total_blocks = object.get_deprecated("total_block_count"sv).to_u64();
|
||||
if (total_blocks == 0)
|
||||
return 0;
|
||||
auto free_blocks = object.get("free_block_count"sv).to_u64();
|
||||
auto free_blocks = object.get_deprecated("free_block_count"sv).to_u64();
|
||||
auto used_blocks = total_blocks - free_blocks;
|
||||
int percentage = (static_cast<double>(used_blocks) / static_cast<double>(total_blocks) * 100.0);
|
||||
return percentage;
|
||||
|
@ -149,31 +149,31 @@ public:
|
|||
df_fields.empend(
|
||||
"Used", Gfx::TextAlignment::CenterRight,
|
||||
[](const JsonObject& object) {
|
||||
auto total_blocks = object.get("total_block_count"sv).to_u64();
|
||||
auto free_blocks = object.get("free_block_count"sv).to_u64();
|
||||
auto total_blocks = object.get_deprecated("total_block_count"sv).to_u64();
|
||||
auto free_blocks = object.get_deprecated("free_block_count"sv).to_u64();
|
||||
auto used_blocks = total_blocks - free_blocks;
|
||||
return human_readable_size(used_blocks * object.get("block_size"sv).to_u64()); },
|
||||
return human_readable_size(used_blocks * object.get_deprecated("block_size"sv).to_u64()); },
|
||||
[](const JsonObject& object) {
|
||||
auto total_blocks = object.get("total_block_count"sv).to_u64();
|
||||
auto free_blocks = object.get("free_block_count"sv).to_u64();
|
||||
auto total_blocks = object.get_deprecated("total_block_count"sv).to_u64();
|
||||
auto free_blocks = object.get_deprecated("free_block_count"sv).to_u64();
|
||||
auto used_blocks = total_blocks - free_blocks;
|
||||
return used_blocks * object.get("block_size"sv).to_u64();
|
||||
return used_blocks * object.get_deprecated("block_size"sv).to_u64();
|
||||
});
|
||||
df_fields.empend(
|
||||
"Available", Gfx::TextAlignment::CenterRight,
|
||||
[](const JsonObject& object) {
|
||||
return human_readable_size(object.get("free_block_count"sv).to_u64() * object.get("block_size"sv).to_u64());
|
||||
return human_readable_size(object.get_deprecated("free_block_count"sv).to_u64() * object.get_deprecated("block_size"sv).to_u64());
|
||||
},
|
||||
[](const JsonObject& object) {
|
||||
return object.get("free_block_count"sv).to_u64() * object.get("block_size"sv).to_u64();
|
||||
return object.get_deprecated("free_block_count"sv).to_u64() * object.get_deprecated("block_size"sv).to_u64();
|
||||
});
|
||||
df_fields.empend("Access", Gfx::TextAlignment::CenterLeft, [](const JsonObject& object) {
|
||||
bool readonly = object.get("readonly"sv).to_bool();
|
||||
int mount_flags = object.get("mount_flags"sv).to_int();
|
||||
bool readonly = object.get_deprecated("readonly"sv).to_bool();
|
||||
int mount_flags = object.get_deprecated("mount_flags"sv).to_int();
|
||||
return readonly || (mount_flags & MS_RDONLY) ? "Read-only" : "Read/Write";
|
||||
});
|
||||
df_fields.empend("Mount flags", Gfx::TextAlignment::CenterLeft, [](const JsonObject& object) {
|
||||
int mount_flags = object.get("mount_flags"sv).to_int();
|
||||
int mount_flags = object.get_deprecated("mount_flags"sv).to_int();
|
||||
StringBuilder builder;
|
||||
bool first = true;
|
||||
auto check = [&](int flag, StringView name) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue