mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:32:46 +00:00 
			
		
		
		
	SystemMonitor: Replace uses of JsonObject::get_deprecated()/get_ptr()
This commit is contained in:
		
							parent
							
								
									2df57d5ae0
								
							
						
					
					
						commit
						6fdfa9f313
					
				
					 5 changed files with 31 additions and 31 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_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(); | ||||
|     u32 kmalloc_allocated = json.get_u32("kmalloc_allocated"sv).value_or(0); | ||||
|     u32 kmalloc_available = json.get_u32("kmalloc_available"sv).value_or(0); | ||||
|     u64 physical_allocated = json.get_u64("physical_allocated"sv).value_or(0); | ||||
|     u64 physical_available = json.get_u64("physical_available"sv).value_or(0); | ||||
|     u64 physical_committed = json.get_u64("physical_committed"sv).value_or(0); | ||||
|     u64 physical_uncommitted = json.get_u64("physical_uncommitted"sv).value_or(0); | ||||
|     u32 kmalloc_call_count = json.get_u32("kmalloc_call_count"sv).value_or(0); | ||||
|     u32 kfree_call_count = json.get_u32("kfree_call_count"sv).value_or(0); | ||||
| 
 | ||||
|     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_deprecated("link_up"sv).as_bool()) | ||||
|                 if (!object.get_bool("link_up"sv).value_or(false)) | ||||
|                     return *m_network_link_down_bitmap; | ||||
|                 else | ||||
|                     return object.get_deprecated("ipv4_address"sv).as_string_or(""sv).is_empty() ? *m_network_disconnected_bitmap : *m_network_connected_bitmap; | ||||
|                     return object.get_deprecated_string("ipv4_address"sv).value_or("").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_deprecated("link_up"sv).as_bool()) | ||||
|                 if (!object.get_bool("link_up"sv).value_or(false)) | ||||
|                     return "Down"; | ||||
| 
 | ||||
|                 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); | ||||
|                 return DeprecatedString::formatted("{} Mb/s {}-duplex", object.get_i32("link_speed"sv).value_or(0), | ||||
|                     object.get_bool("link_full_duplex"sv).value_or(false) ? "full"sv : "half"sv); | ||||
|             }); | ||||
|         net_adapters_fields.empend("IPv4", Gfx::TextAlignment::CenterLeft, | ||||
|             [](JsonObject const& object) -> DeprecatedString { | ||||
|                 return object.get_deprecated("ipv4_address"sv).as_string_or(""sv); | ||||
|                 return object.get_deprecated_string("ipv4_address"sv).value_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_deprecated("seekable"sv).to_bool() ? "Seekable" : "Sequential"; | ||||
|         return object.get_bool("seekable"sv).value_or(false) ? "Seekable" : "Sequential"; | ||||
|     }); | ||||
|     pid_fds_fields.empend("Blocking", Gfx::TextAlignment::CenterLeft, [](auto& object) { | ||||
|         return object.get_deprecated("blocking"sv).to_bool() ? "Blocking" : "Nonblocking"; | ||||
|         return object.get_bool("blocking"sv).value_or(false) ? "Blocking" : "Nonblocking"; | ||||
|     }); | ||||
|     pid_fds_fields.empend("On exec", Gfx::TextAlignment::CenterLeft, [](auto& object) { | ||||
|         return object.get_deprecated("cloexec"sv).to_bool() ? "Close" : "Keep"; | ||||
|         return object.get_bool("cloexec"sv).value_or(false) ? "Close" : "Keep"; | ||||
|     }); | ||||
|     pid_fds_fields.empend("Can read", Gfx::TextAlignment::CenterLeft, [](auto& object) { | ||||
|         return object.get_deprecated("can_read"sv).to_bool() ? "Yes" : "No"; | ||||
|         return object.get_bool("can_read"sv).value_or(false) ? "Yes" : "No"; | ||||
|     }); | ||||
|     pid_fds_fields.empend("Can write", Gfx::TextAlignment::CenterLeft, [](auto& object) { | ||||
|         return object.get_deprecated("can_write"sv).to_bool() ? "Yes" : "No"; | ||||
|         return object.get_bool("can_write"sv).value_or(false) ? "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_deprecated("address"sv).to_u64()); }, | ||||
|         [](auto& object) { return object.get_deprecated("address"sv).to_u64(); }); | ||||
|         [](auto& object) { return DeprecatedString::formatted("{:p}", object.get_u64("address"sv).value_or(0)); }, | ||||
|         [](auto& object) { return object.get_u64("address"sv).value_or(0); }); | ||||
|     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_deprecated("readable"sv).to_bool()) | ||||
|         if (object.get_bool("readable"sv).value_or(false)) | ||||
|             builder.append('R'); | ||||
|         if (object.get_deprecated("writable"sv).to_bool()) | ||||
|         if (object.get_bool("writable"sv).value_or(false)) | ||||
|             builder.append('W'); | ||||
|         if (object.get_deprecated("executable"sv).to_bool()) | ||||
|         if (object.get_bool("executable"sv).value_or(false)) | ||||
|             builder.append('X'); | ||||
|         if (object.get_deprecated("shared"sv).to_bool()) | ||||
|         if (object.get_bool("shared"sv).value_or(false)) | ||||
|             builder.append('S'); | ||||
|         if (object.get_deprecated("syscall"sv).to_bool()) | ||||
|         if (object.get_bool("syscall"sv).value_or(false)) | ||||
|             builder.append('C'); | ||||
|         if (object.get_deprecated("stack"sv).to_bool()) | ||||
|         if (object.get_bool("stack"sv).value_or(false)) | ||||
|             builder.append('T'); | ||||
|         return builder.to_deprecated_string(); | ||||
|     }); | ||||
|     pid_vm_fields.empend("VMObject type", Gfx::TextAlignment::CenterLeft, [](auto& object) { | ||||
|         auto type = object.get_deprecated("vmobject"sv).to_deprecated_string(); | ||||
|         auto type = object.get_deprecated_string("vmobject"sv).value_or({}); | ||||
|         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_deprecated("volatile"sv).to_bool()) | ||||
|         if (object.get_bool("volatile"sv).value_or(false)) | ||||
|             return "Volatile"; | ||||
|         return "Non-volatile"; | ||||
|     }); | ||||
|  | @ -98,7 +98,7 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget() | |||
|             return GUI::Variant(0); | ||||
|         }, | ||||
|         [](JsonObject const& object) { | ||||
|             auto pagemap = object.get_deprecated("pagemap"sv).as_string_or({}); | ||||
|             auto pagemap = object.get_deprecated_string("pagemap"sv).value_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_deprecated("processor"sv).as_u32(); | ||||
|             auto cpu_id = cpu_object.get_u32("processor"sv).value(); | ||||
|             m_cpus.append(make<CpuInfo>(cpu_id)); | ||||
|         }); | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sam Atkins
						Sam Atkins