Repository navigation
Extract IOKit iteration into IOKitProvider callback pattern - #3264
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (13)
🚧 Files skipped from review as they are similar to previous changes (11)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
🔇 Additional comments (2)
📝 WalkthroughWalkthroughAdds an IOKitProvider interface and RegistryEntry contract, implements JNA and FFM provider singletons, updates common Mac base classes to use ioKitProvider() for platform/CPU discovery, and migrates JNA/FFM mac subclasses to return the corresponding provider instances. ChangesIOKit Provider Architecture and Base Class Refactoring
JNA IOKit Provider Implementation and Subclass Migration
FFM IOKit Provider Implementation and Subclass Migration
Sequence DiagramsequenceDiagram
participant Base as MacCentralProcessor (base)
participant ProviderHook as ioKitProvider()
participant ProviderImpl as IOKitProviderJNA/IOKitProviderFFM
participant Registry as IORegistryEntry
Base->>ProviderHook: call
ProviderHook-->>Base: provider instance
Base->>ProviderImpl: withMatchingService("IOPlatformExpertDevice", extractor)
ProviderImpl->>Registry: lookup service
Registry-->>ProviderImpl: IORegistryEntry
ProviderImpl->>ProviderImpl: wrap -> RegistryEntry
ProviderImpl-->>Base: apply extractor result
Base->>Base: decode properties (UTF-8), normalize
ProviderImpl->>Registry: release entry (finally)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Introduce an IOKitProvider interface in oshi-common that abstracts IOKit registry operations (getMatchingService, iteration, property access). JNA and FFM each provide a singleton implementation. Move duplicated IOKit logic from MacCentralProcessor, MacBaseboard, and MacComputerSystem subclasses into their common base classes, which now use the provider. This eliminates ~330 lines of duplicated iteration code across the JNA/FFM pairs.
4e10c91 to
0ad54d8
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3264 +/- ##
============================================
+ Coverage 74.19% 74.25% +0.05%
Complexity 73 73
============================================
Files 397 399 +2
Lines 16091 16029 -62
Branches 2587 2555 -32
============================================
- Hits 11939 11902 -37
+ Misses 2636 2633 -3
+ Partials 1516 1494 -22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Closes #3260
Introduces an
IOKitProviderinterface inoshi-commonthat abstracts IOKit registry operations, with JNA and FFM singleton implementations. Duplicated IOKit iteration logic is moved from subclasses into the common base classes.New files:
IOKitProvider.java— interface withwithMatchingService,forEachMatchingService,forEachMatchingServiceUntil, andRegistryEntryIOKitProviderJNA.java/IOKitProviderFFM.java— implementationsRefactored base classes (logic moved in):
MacCentralProcessor—platformExpert(),queryCompatibleStrings(),calculateNominalFrequencies()MacBaseboard—queryPlatform()MacComputerSystem—platformExpert()Simplified subclasses (~330 lines removed):
MacCentralProcessorJNA/FFM— removed IOKit methods, just implementioKitProvider()MacBaseboardJNA/FFM— reduced toioKitProvider()onlyMacComputerSystemJNA/FFM— reduced toioKitProvider()+ factory methodsClasses using
getChildIterator(MacFirmware, MacUsbDevice) are not addressed here as they require a more complex lifecycle pattern.Summary by CodeRabbit