diff --git a/crates/header-translator/src/config.rs b/crates/header-translator/src/config.rs index 53aa12abf..08a5d5f5c 100644 --- a/crates/header-translator/src/config.rs +++ b/crates/header-translator/src/config.rs @@ -3,13 +3,14 @@ use std::error::Error; use std::fmt; use std::fs; use std::path::Path; +use std::str::FromStr; use heck::ToTrainCase; use semver::Version; use serde::{de, Deserialize, Deserializer}; use crate::stmt::{Counterpart, Derives}; -use crate::ItemIdentifier; +use crate::{ItemIdentifier, Location}; #[derive(Debug, Clone, PartialEq, Eq)] pub struct Config { @@ -92,16 +93,16 @@ fn get_version<'de, D: Deserializer<'de>>(deserializer: D) -> Result, #[serde(rename = "required-items")] #[serde(default)] - pub required_items: Vec, + pub required_items: Vec, } #[derive(Deserialize, Debug, Default, Clone, PartialEq, Eq)] @@ -342,27 +343,18 @@ impl LibraryConfig { } } -impl<'de> Deserialize<'de> for Counterpart { +impl<'de> de::Deserialize<'de> for Counterpart { fn deserialize(deserializer: D) -> Result where - D: Deserializer<'de>, + D: de::Deserializer<'de>, { - fn parse_itemidentifier(value: &str) -> Option { - let (library, rest) = value.split_once("::")?; - let (file_name, name) = rest.split_once("::")?; - Some(ItemIdentifier::from_raw( - name.into(), - vec![library.to_string().into(), file_name.to_string().into()], - )) - } - struct CounterpartVisitor; impl de::Visitor<'_> for CounterpartVisitor { type Value = Counterpart; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("counterpart") + formatter.write_str("item identifier") } fn visit_str(self, value: &str) -> Result @@ -372,18 +364,16 @@ impl<'de> Deserialize<'de> for Counterpart { if let Some(value) = value.strip_prefix("ImmutableSuperclass(") { let value = value .strip_suffix(')') - .ok_or(de::Error::custom("end parenthesis"))?; - let item = - parse_itemidentifier(value).ok_or(de::Error::custom("requires ::"))?; + .ok_or_else(|| de::Error::custom("end parenthesis"))?; + let item = ItemIdentifier::from_str(value).map_err(de::Error::custom)?; return Ok(Counterpart::ImmutableSuperclass(item)); } if let Some(value) = value.strip_prefix("MutableSubclass(") { let value = value .strip_suffix(')') - .ok_or(de::Error::custom("end parenthesis"))?; - let item = - parse_itemidentifier(value).ok_or(de::Error::custom("requires ::"))?; + .ok_or_else(|| de::Error::custom("end parenthesis"))?; + let item = ItemIdentifier::from_str(value).map_err(de::Error::custom)?; return Ok(Counterpart::MutableSubclass(item)); } diff --git a/crates/header-translator/src/id.rs b/crates/header-translator/src/id.rs index 12dc29fab..79ee971c9 100644 --- a/crates/header-translator/src/id.rs +++ b/crates/header-translator/src/id.rs @@ -1,10 +1,13 @@ use core::fmt; use core::hash; +use serde::de; use std::borrow::Cow; use std::cmp::Ordering; use std::collections::BTreeSet; +use std::error::Error; +use std::str::FromStr; -use clang::source::{File, Module}; +use clang::source::File; use clang::Entity; use crate::cfgs::PlatformCfg; @@ -37,7 +40,8 @@ impl ToOptionString for () { #[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct Location { - path_components: Vec>, + // A Swift/Clang module path (dot-separated). + module_path: Box, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] @@ -125,50 +129,51 @@ impl<'config> LocationLibrary<'_, 'config> { } impl Location { - fn from_module(module: Module<'_>) -> Self { - let full_name = module.get_full_name(); + fn new(module_path: impl Into>) -> Self { + let module_path = module_path.into(); + let module_path = match &*module_path { + // blocks + "block" => "block2".into(), - Location::from_components(match &*full_name { // Objective-C - name if name.starts_with("ObjectiveC") => vec!["objc2".into()], + name if name.starts_with("ObjectiveC") => "objc2".into(), // Redefined in the framework crate itself. - "Darwin.MacTypes" => vec!["System".into()], + "Darwin.MacTypes" => "System".into(), // Built-ins - "DarwinFoundation.types.machine_types" => vec!["System".into()], - "_Builtin_stdarg.va_list" => vec!["System".into()], + "DarwinFoundation.types.machine_types" => "System".into(), + "_Builtin_stdarg.va_list" => "System".into(), // Libc - name if name.starts_with("sys_types") => vec!["libc".into()], - "DarwinFoundation.types.sys_types" => vec!["libc".into()], - "DarwinFoundation.qos" => vec!["libc".into()], - name if name.starts_with("Darwin.POSIX") => vec!["libc".into()], - "_stdio" => vec!["libc".into()], - "_time.timespec" => vec!["libc".into()], + name if name.starts_with("sys_types") => "libc".into(), + "DarwinFoundation.types.sys_types" => "libc".into(), + "DarwinFoundation.qos" => "libc".into(), + name if name.starts_with("Darwin.POSIX") => "libc".into(), + "_stdio" => "libc".into(), + "_time.timespec" => "libc".into(), // Will be moved to the `mach2` crate in `libc` v1.0 - name if name.starts_with("Darwin.Mach") => vec!["libc".into()], - "_mach_port_t" => vec!["libc".into()], + name if name.starts_with("Darwin.Mach") => "libc".into(), + "_mach_port_t" => "libc".into(), - full_name => full_name - .split('.') - .map(|component| Cow::Owned(component.to_string())) - .collect(), - }) + _ => module_path, + }; + + Self { module_path } } pub fn from_file(file: File<'_>) -> Self { // Get from module first if available if let Some(module) = file.get_module() { - return Location::from_module(module); + return Self::new(module.get_full_name()); } let path = file.get_path(); if !path.to_string_lossy().contains("System/Library/Frameworks") { // Likely a built-in macro from stddef.h, stdarg.h or assert.h. - return Location::from_components(vec!["System".into()]); + return Self::new("System"); } // The item likely comes from a private sub-framework, so let's try @@ -197,35 +202,35 @@ impl Location { } } - Self::from_components(components) - } - - pub(crate) fn components( - &self, - ) -> impl DoubleEndedIterator + ExactSizeIterator + '_ { - self.path_components.iter().map(|c| &**c) - } - - pub(crate) fn from_components(path_components: Vec>) -> Self { - Self { path_components } + Self { + module_path: components.join(".").into_boxed_str(), + } } pub fn library_name(&self) -> &str { - self.path_components - .first() - .expect("location to have at least one component") + if let Some((library, _rest)) = self.module_path.split_once('.') { + library + } else { + // Top-level + &self.module_path + } } fn file_name(&self) -> Option<&str> { - match &*self.path_components { - [_, .., file_name] => Some(&**file_name), + if let Some((_umbrella, rest)) = self.module_path.split_once('.') { + if let Some((_rest, file_name)) = rest.rsplit_once('.') { + Some(file_name) + } else { + Some(rest) + } + } else { // Umbrella header - [_] | [] => None, + None } } pub fn modules(&self) -> impl IntoIterator + '_ { - self.path_components.iter().skip(1).map(|s| &**s) + self.module_path.split('.').skip(1) } pub fn library<'location, 'config>( @@ -317,11 +322,8 @@ impl ItemIdentifier { self.location.library_name() } - pub fn from_raw(name: N, path_components: Vec>) -> Self { - Self { - name, - location: Location { path_components }, - } + pub fn from_raw(name: N, location: Location) -> Self { + Self { name, location } } pub fn with_name(name: N, entity: &Entity<'_>, _context: &Context<'_>) -> Self { @@ -336,7 +338,7 @@ impl ItemIdentifier { // Defined in multiple places for some reason. if let Some("IOSurfaceRef" | "__IOSurface") = name.to_option() { - location = Location::from_components(vec!["IOSurface".into(), "IOSurfaceRef".into()]); + location = Location::new("IOSurface.IOSurfaceRef"); } Self { name, location } @@ -383,35 +385,35 @@ impl ItemIdentifier { pub fn nserror() -> Self { Self { name: "NSError".into(), - location: Location::from_components(vec!["Foundation".into(), "NSError".into()]), + location: Location::new("Foundation.NSError"), } } pub fn block() -> Self { Self { name: "Block".into(), - location: Location::from_components(vec!["block2".into()]), + location: Location::new("block"), } } pub fn bitflags() -> Self { Self { name: "bitflags".into(), - location: Location::from_components(vec!["bitflags".into()]), + location: Location::new("bitflags"), } } pub fn objc2(name: impl Into) -> Self { Self { name: name.into(), - location: Location::from_components(vec!["objc2".into()]), + location: Location::new("ObjectiveC"), } } pub fn main_thread_marker() -> Self { Self { name: "MainThreadMarker".into(), - location: Location::from_components(vec!["objc2".into()]), + location: Location::new("ObjectiveC"), } } @@ -419,7 +421,7 @@ impl ItemIdentifier { pub fn dummy() -> Self { Self { name: "DUMMY".into(), - location: Location::from_components(vec!["System".into()]), + location: Location::new("System"), } } @@ -568,3 +570,89 @@ pub fn cfg_gate_ln<'a, R: AsRef + 'a, I: AsRef + 'a>( Ok(()) }) } + +impl FromStr for Location { + type Err = Box; + + fn from_str(s: &str) -> Result { + if s.contains("::") { + return Err(Box::new(std::io::Error::other("requires ., not ::"))); + } + + Ok(Location { + module_path: s.into(), + }) + } +} + +impl<'de> de::Deserialize<'de> for Location { + fn deserialize(deserializer: D) -> Result + where + D: de::Deserializer<'de>, + { + struct LocationVisitor; + + impl de::Visitor<'_> for LocationVisitor { + type Value = Location; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("location") + } + + fn visit_str(self, value: &str) -> Result + where + E: de::Error, + { + Location::from_str(value).map_err(de::Error::custom) + } + } + + deserializer.deserialize_str(LocationVisitor) + } +} + +impl FromStr for ItemIdentifier { + type Err = Box; + fn from_str(s: &str) -> Result { + if s.contains("::") { + return Err(Box::new(std::io::Error::other("requires ., not ::"))); + } + + let (module_path, name) = s + .rsplit_once('.') + .ok_or_else(|| std::io::Error::other("requires at least one ."))?; + + Ok(Self { + name: name.into(), + location: Location { + module_path: module_path.into(), + }, + }) + } +} + +impl<'de> de::Deserialize<'de> for ItemIdentifier { + fn deserialize(deserializer: D) -> Result + where + D: de::Deserializer<'de>, + { + struct ItemIdentifierVisitor; + + impl de::Visitor<'_> for ItemIdentifierVisitor { + type Value = ItemIdentifier; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("item identifier") + } + + fn visit_str(self, value: &str) -> Result + where + E: de::Error, + { + ItemIdentifier::from_str(value).map_err(de::Error::custom) + } + } + + deserializer.deserialize_str(ItemIdentifierVisitor) + } +} diff --git a/crates/header-translator/src/library.rs b/crates/header-translator/src/library.rs index b097dda56..2f70be4a4 100644 --- a/crates/header-translator/src/library.rs +++ b/crates/header-translator/src/library.rs @@ -38,14 +38,14 @@ impl Library { pub fn add_module(&mut self, location: Location) { let mut current = &mut self.module; - for component in location.components().skip(1) { + for component in location.modules() { current = current.submodules.entry(component.into()).or_default(); } } pub fn module_mut(&mut self, location: Location) -> &mut Module { let mut current = &mut self.module; - for component in location.components().skip(1) { + for component in location.modules() { current = match current.submodules.entry(component.into()) { Entry::Occupied(entry) => entry.into_mut(), Entry::Vacant(entry) => { diff --git a/crates/header-translator/src/rust_type.rs b/crates/header-translator/src/rust_type.rs index 400797117..4f2976568 100644 --- a/crates/header-translator/src/rust_type.rs +++ b/crates/header-translator/src/rust_type.rs @@ -1,4 +1,3 @@ -use std::borrow::Cow; use std::str::FromStr; use std::{fmt, iter}; @@ -351,14 +350,7 @@ impl ItemRef { let mut id = ItemIdentifier::new(&entity, context); if let Some(external) = context.library(id.library_name()).external.get(&id.name) { - let id = ItemIdentifier::from_raw( - id.name, - external - .module - .split('.') - .map(|x| x.to_string().into()) - .collect(), - ); + let id = ItemIdentifier::from_raw(id.name, external.module.clone()); let thread_safety = external .thread_safety .as_deref() @@ -367,14 +359,7 @@ impl ItemRef { let required_items = external .required_items .iter() - .map(|s| { - let mut components: Vec> = - s.split('.').map(|x| x.to_string().into()).collect(); - let name = components - .pop() - .expect("required items component at least one"); - ItemIdentifier::from_raw(name.to_string(), components) - }) + .cloned() .chain(iter::once(id.clone())) .collect(); return Self { diff --git a/framework-crates/objc2-app-kit/translation-config.toml b/framework-crates/objc2-app-kit/translation-config.toml index b03fa815c..18da0d862 100644 --- a/framework-crates/objc2-app-kit/translation-config.toml +++ b/framework-crates/objc2-app-kit/translation-config.toml @@ -26,10 +26,10 @@ static.NSApp.skipped = true class.NSTextStorage.skipped-protocols = ["NSCopying", "NSMutableCopying"] # Set counterparts -class.NSFontCollection.counterpart = "MutableSubclass(AppKit::NSFontCollection::NSMutableFontCollection)" -class.NSMutableFontCollection.counterpart = "ImmutableSuperclass(AppKit::NSFontCollection::NSFontCollection)" -class.NSParagraphStyle.counterpart = "MutableSubclass(AppKit::NSParagraphStyle::NSMutableParagraphStyle)" -class.NSMutableParagraphStyle.counterpart = "ImmutableSuperclass(AppKit::NSParagraphStyle::NSParagraphStyle)" +class.NSFontCollection.counterpart = "MutableSubclass(AppKit.NSFontCollection.NSMutableFontCollection)" +class.NSMutableFontCollection.counterpart = "ImmutableSuperclass(AppKit.NSFontCollection.NSFontCollection)" +class.NSParagraphStyle.counterpart = "MutableSubclass(AppKit.NSParagraphStyle.NSMutableParagraphStyle)" +class.NSMutableParagraphStyle.counterpart = "ImmutableSuperclass(AppKit.NSParagraphStyle.NSParagraphStyle)" # Typedef that uses a generic from a class typedef.NSCollectionViewDiffableDataSourceItemProvider.skipped = true diff --git a/framework-crates/objc2-av-foundation/translation-config.toml b/framework-crates/objc2-av-foundation/translation-config.toml index a4c770df5..aa301e505 100644 --- a/framework-crates/objc2-av-foundation/translation-config.toml +++ b/framework-crates/objc2-av-foundation/translation-config.toml @@ -83,35 +83,35 @@ class.AVPortraitEffectsMatte.methods."portraitEffectsMatteByApplyingExifOrientat class.AVSemanticSegmentationMatte.methods."semanticSegmentationMatteByApplyingExifOrientation:".skipped = true # Counterparts -class.AVAssetDownloadStorageManagementPolicy.counterpart = "MutableSubclass(AVFoundation::AVAssetDownloadStorageManager::AVMutableAssetDownloadStorageManagementPolicy)" -class.AVMutableAssetDownloadStorageManagementPolicy.counterpart = "ImmutableSuperclass(AVFoundation::AVAssetDownloadStorageManager::AVAssetDownloadStorageManagementPolicy)" -class.AVAudioMix.counterpart = "MutableSubclass(AVFoundation::AVAudioMix::AVMutableAudioMix)" -class.AVMutableAudioMix.counterpart = "ImmutableSuperclass(AVFoundation::AVAudioMix::AVAudioMix)" -class.AVAudioMixInputParameters.counterpart = "MutableSubclass(AVFoundation::AVAudioMix::AVMutableAudioMixInputParameters)" -class.AVMutableAudioMixInputParameters.counterpart = "ImmutableSuperclass(AVFoundation::AVAudioMix::AVAudioMixInputParameters)" -class.AVMediaSelection.counterpart = "MutableSubclass(AVFoundation::AVMediaSelection::AVMutableMediaSelection)" -class.AVMutableMediaSelection.counterpart = "ImmutableSuperclass(AVFoundation::AVMediaSelection::AVMediaSelection)" -class.AVMetadataItem.counterpart = "MutableSubclass(AVFoundation::AVMetadataItem::AVMutableMetadataItem)" -class.AVMutableMetadataItem.counterpart = "ImmutableSuperclass(AVFoundation::AVMetadataItem::AVMetadataItem)" -class.AVMovie.counterpart = "MutableSubclass(AVFoundation::AVMovie::AVMutableMovie)" -class.AVMutableMovie.counterpart = "ImmutableSuperclass(AVFoundation::AVMovie::AVMovie)" +class.AVAssetDownloadStorageManagementPolicy.counterpart = "MutableSubclass(AVFoundation.AVAssetDownloadStorageManager.AVMutableAssetDownloadStorageManagementPolicy)" +class.AVMutableAssetDownloadStorageManagementPolicy.counterpart = "ImmutableSuperclass(AVFoundation.AVAssetDownloadStorageManager.AVAssetDownloadStorageManagementPolicy)" +class.AVAudioMix.counterpart = "MutableSubclass(AVFoundation.AVAudioMix.AVMutableAudioMix)" +class.AVMutableAudioMix.counterpart = "ImmutableSuperclass(AVFoundation.AVAudioMix.AVAudioMix)" +class.AVAudioMixInputParameters.counterpart = "MutableSubclass(AVFoundation.AVAudioMix.AVMutableAudioMixInputParameters)" +class.AVMutableAudioMixInputParameters.counterpart = "ImmutableSuperclass(AVFoundation.AVAudioMix.AVAudioMixInputParameters)" +class.AVMediaSelection.counterpart = "MutableSubclass(AVFoundation.AVMediaSelection.AVMutableMediaSelection)" +class.AVMutableMediaSelection.counterpart = "ImmutableSuperclass(AVFoundation.AVMediaSelection.AVMediaSelection)" +class.AVMetadataItem.counterpart = "MutableSubclass(AVFoundation.AVMetadataItem.AVMutableMetadataItem)" +class.AVMutableMetadataItem.counterpart = "ImmutableSuperclass(AVFoundation.AVMetadataItem.AVMetadataItem)" +class.AVMovie.counterpart = "MutableSubclass(AVFoundation.AVMovie.AVMutableMovie)" +class.AVMutableMovie.counterpart = "ImmutableSuperclass(AVFoundation.AVMovie.AVMovie)" class.AVFragmentedMovie.skipped-protocols = ["NSCopying", "NSMutableCopying"] # Unclear what type these return -class.AVTimedMetadataGroup.counterpart = "MutableSubclass(AVFoundation::AVTimedMetadataGroup::AVMutableTimedMetadataGroup)" -class.AVMutableTimedMetadataGroup.counterpart = "ImmutableSuperclass(AVFoundation::AVTimedMetadataGroup::AVTimedMetadataGroup)" -class.AVDateRangeMetadataGroup.counterpart = "MutableSubclass(AVFoundation::AVTimedMetadataGroup::AVMutableDateRangeMetadataGroup)" -class.AVMutableDateRangeMetadataGroup.counterpart = "ImmutableSuperclass(AVFoundation::AVTimedMetadataGroup::AVDateRangeMetadataGroup)" -class.AVVideoComposition.counterpart = "MutableSubclass(AVFoundation::AVVideoComposition::AVMutableVideoComposition)" -class.AVMutableVideoComposition.counterpart = "ImmutableSuperclass(AVFoundation::AVVideoComposition::AVVideoComposition)" -class.AVVideoCompositionInstruction.counterpart = "MutableSubclass(AVFoundation::AVVideoComposition::AVMutableVideoCompositionInstruction)" -class.AVMutableVideoCompositionInstruction.counterpart = "ImmutableSuperclass(AVFoundation::AVVideoComposition::AVVideoCompositionInstruction)" -class.AVVideoCompositionLayerInstruction.counterpart = "MutableSubclass(AVFoundation::AVVideoComposition::AVMutableVideoCompositionLayerInstruction)" -class.AVMutableVideoCompositionLayerInstruction.counterpart = "ImmutableSuperclass(AVFoundation::AVVideoComposition::AVVideoCompositionInstruction)" -class.AVCaption.counterpart = "MutableSubclass(AVFoundation::AVCaption::AVMutableCaption)" -class.AVMutableCaption.counterpart = "ImmutableSuperclass(AVFoundation::AVCaption::AVCaption)" -class.AVCaptionRegion.counterpart = "MutableSubclass(AVFoundation::AVCaption::AVMutableCaptionRegion)" -class.AVMutableCaptionRegion.counterpart = "ImmutableSuperclass(AVFoundation::AVCaption::AVCaptionRegion)" -class.AVComposition.counterpart = "MutableSubclass(AVFoundation::AVComposition::AVMutableComposition)" -class.AVMutableComposition.counterpart = "ImmutableSuperclass(AVFoundation::AVComposition::AVComposition)" +class.AVTimedMetadataGroup.counterpart = "MutableSubclass(AVFoundation.AVTimedMetadataGroup.AVMutableTimedMetadataGroup)" +class.AVMutableTimedMetadataGroup.counterpart = "ImmutableSuperclass(AVFoundation.AVTimedMetadataGroup.AVTimedMetadataGroup)" +class.AVDateRangeMetadataGroup.counterpart = "MutableSubclass(AVFoundation.AVTimedMetadataGroup.AVMutableDateRangeMetadataGroup)" +class.AVMutableDateRangeMetadataGroup.counterpart = "ImmutableSuperclass(AVFoundation.AVTimedMetadataGroup.AVDateRangeMetadataGroup)" +class.AVVideoComposition.counterpart = "MutableSubclass(AVFoundation.AVVideoComposition.AVMutableVideoComposition)" +class.AVMutableVideoComposition.counterpart = "ImmutableSuperclass(AVFoundation.AVVideoComposition.AVVideoComposition)" +class.AVVideoCompositionInstruction.counterpart = "MutableSubclass(AVFoundation.AVVideoComposition.AVMutableVideoCompositionInstruction)" +class.AVMutableVideoCompositionInstruction.counterpart = "ImmutableSuperclass(AVFoundation.AVVideoComposition.AVVideoCompositionInstruction)" +class.AVVideoCompositionLayerInstruction.counterpart = "MutableSubclass(AVFoundation.AVVideoComposition.AVMutableVideoCompositionLayerInstruction)" +class.AVMutableVideoCompositionLayerInstruction.counterpart = "ImmutableSuperclass(AVFoundation.AVVideoComposition.AVVideoCompositionInstruction)" +class.AVCaption.counterpart = "MutableSubclass(AVFoundation.AVCaption.AVMutableCaption)" +class.AVMutableCaption.counterpart = "ImmutableSuperclass(AVFoundation.AVCaption.AVCaption)" +class.AVCaptionRegion.counterpart = "MutableSubclass(AVFoundation.AVCaption.AVMutableCaptionRegion)" +class.AVMutableCaptionRegion.counterpart = "ImmutableSuperclass(AVFoundation.AVCaption.AVCaptionRegion)" +class.AVComposition.counterpart = "MutableSubclass(AVFoundation.AVComposition.AVMutableComposition)" +class.AVMutableComposition.counterpart = "ImmutableSuperclass(AVFoundation.AVComposition.AVComposition)" # Both protocols and classes protocol.AVVideoCompositionInstruction.renamed = "AVVideoCompositionInstructionProtocol" diff --git a/framework-crates/objc2-contacts/translation-config.toml b/framework-crates/objc2-contacts/translation-config.toml index 05624f4be..c7fd19088 100644 --- a/framework-crates/objc2-contacts/translation-config.toml +++ b/framework-crates/objc2-contacts/translation-config.toml @@ -8,9 +8,9 @@ watchos = "2.0" visionos = "1.0" # Set counterparts -class.CNContact.counterpart = "MutableSubclass(Contacts::CNMutableContact::CNMutableContact)" -class.CNMutableContact.counterpart = "ImmutableSuperclass(Contacts::CNContact::CNContact)" -class.CNGroup.counterpart = "MutableSubclass(Contacts::CNMutableGroup::CNMutableGroup)" -class.CNMutableGroup.counterpart = "ImmutableSuperclass(Contacts::CNGroup::CNGroup)" -class.CNPostalAddress.counterpart = "MutableSubclass(Contacts::CNMutablePostalAddress::CNMutablePostalAddress)" -class.CNMutablePostalAddress.counterpart = "ImmutableSuperclass(Contacts::CNPostalAddress::CNPostalAddress)" +class.CNContact.counterpart = "MutableSubclass(Contacts.CNMutableContact.CNMutableContact)" +class.CNMutableContact.counterpart = "ImmutableSuperclass(Contacts.CNContact.CNContact)" +class.CNGroup.counterpart = "MutableSubclass(Contacts.CNMutableGroup.CNMutableGroup)" +class.CNMutableGroup.counterpart = "ImmutableSuperclass(Contacts.CNGroup.CNGroup)" +class.CNPostalAddress.counterpart = "MutableSubclass(Contacts.CNMutablePostalAddress.CNMutablePostalAddress)" +class.CNMutablePostalAddress.counterpart = "ImmutableSuperclass(Contacts.CNPostalAddress.CNPostalAddress)" diff --git a/framework-crates/objc2-core-wlan/translation-config.toml b/framework-crates/objc2-core-wlan/translation-config.toml index 9f14e2dc5..b0761373c 100644 --- a/framework-crates/objc2-core-wlan/translation-config.toml +++ b/framework-crates/objc2-core-wlan/translation-config.toml @@ -6,10 +6,10 @@ macos = "10.6" maccatalyst = "13.0" # Set counterparts -class.CWConfiguration.counterpart = "MutableSubclass(CoreWLAN::CWConfiguration::CWMutableConfiguration)" -class.CWMutableConfiguration.counterpart = "ImmutableSuperclass(CoreWLAN::CWConfiguration::CWConfiguration)" -class.CWNetworkProfile.counterpart = "MutableSubclass(CoreWLAN::CWNetworkProfile::CWMutableNetworkProfile)" -class.CWMutableNetworkProfile.counterpart = "ImmutableSuperclass(CoreWLAN::CWNetworkProfile::CWNetworkProfile)" +class.CWConfiguration.counterpart = "MutableSubclass(CoreWLAN.CWConfiguration.CWMutableConfiguration)" +class.CWMutableConfiguration.counterpart = "ImmutableSuperclass(CoreWLAN.CWConfiguration.CWConfiguration)" +class.CWNetworkProfile.counterpart = "MutableSubclass(CoreWLAN.CWNetworkProfile.CWMutableNetworkProfile)" +class.CWMutableNetworkProfile.counterpart = "ImmutableSuperclass(CoreWLAN.CWNetworkProfile.CWNetworkProfile)" # Needs SecIdentityRef from Security fn.CWKeychainCopyWiFiEAPIdentity.skipped = true diff --git a/framework-crates/objc2-foundation/translation-config.toml b/framework-crates/objc2-foundation/translation-config.toml index 5dbc4908e..0e67e39bb 100644 --- a/framework-crates/objc2-foundation/translation-config.toml +++ b/framework-crates/objc2-foundation/translation-config.toml @@ -248,38 +248,38 @@ class.NSXPCCoder.methods."decodeXPCObjectOfType:forKey:".skipped = true ### Counterparts ### -class.NSArray.counterpart = "MutableSubclass(Foundation::NSArray::NSMutableArray)" -class.NSMutableArray.counterpart = "ImmutableSuperclass(Foundation::NSArray::NSArray)" +class.NSArray.counterpart = "MutableSubclass(Foundation.NSArray.NSMutableArray)" +class.NSMutableArray.counterpart = "ImmutableSuperclass(Foundation.NSArray.NSArray)" -class.NSString.counterpart = "MutableSubclass(Foundation::NSString::NSMutableString)" -class.NSMutableString.counterpart = "ImmutableSuperclass(Foundation::NSString::NSString)" +class.NSString.counterpart = "MutableSubclass(Foundation.NSString.NSMutableString)" +class.NSMutableString.counterpart = "ImmutableSuperclass(Foundation.NSString.NSString)" -class.NSAttributedString.counterpart = "MutableSubclass(Foundation::NSAttributedString::NSMutableAttributedString)" -class.NSMutableAttributedString.counterpart = "ImmutableSuperclass(Foundation::NSAttributedString::NSAttributedString)" +class.NSAttributedString.counterpart = "MutableSubclass(Foundation.NSAttributedString.NSMutableAttributedString)" +class.NSMutableAttributedString.counterpart = "ImmutableSuperclass(Foundation.NSAttributedString.NSAttributedString)" -class.NSData.counterpart = "MutableSubclass(Foundation::NSData::NSMutableData)" -class.NSMutableData.counterpart = "ImmutableSuperclass(Foundation::NSData::NSData)" +class.NSData.counterpart = "MutableSubclass(Foundation.NSData.NSMutableData)" +class.NSMutableData.counterpart = "ImmutableSuperclass(Foundation.NSData.NSData)" # Auto traits can be deduced as if the dictionary was implemented as `(NSArray, NSArray)`. -class.NSDictionary.counterpart = "MutableSubclass(Foundation::NSDictionary::NSMutableDictionary)" -class.NSMutableDictionary.counterpart = "ImmutableSuperclass(Foundation::NSDictionary::NSDictionary)" +class.NSDictionary.counterpart = "MutableSubclass(Foundation.NSDictionary.NSMutableDictionary)" +class.NSMutableDictionary.counterpart = "ImmutableSuperclass(Foundation.NSDictionary.NSDictionary)" # Auto traits can be viewed as if the set was implemented with `NSArray`. -class.NSSet.counterpart = "MutableSubclass(Foundation::NSSet::NSMutableSet)" -class.NSMutableSet.counterpart = "ImmutableSuperclass(Foundation::NSSet::NSSet)" +class.NSSet.counterpart = "MutableSubclass(Foundation.NSSet.NSMutableSet)" +class.NSMutableSet.counterpart = "ImmutableSuperclass(Foundation.NSSet.NSSet)" -class.NSCharacterSet.counterpart = "MutableSubclass(Foundation::NSCharacterSet::NSMutableCharacterSet)" -class.NSMutableCharacterSet.counterpart = "ImmutableSuperclass(Foundation::NSCharacterSet::NSCharacterSet)" +class.NSCharacterSet.counterpart = "MutableSubclass(Foundation.NSCharacterSet.NSMutableCharacterSet)" +class.NSMutableCharacterSet.counterpart = "ImmutableSuperclass(Foundation.NSCharacterSet.NSCharacterSet)" # Auto traits can be viewed as if the set was implemented with `NSArray`. -class.NSOrderedSet.counterpart = "MutableSubclass(Foundation::NSOrderedSet::NSMutableOrderedSet)" -class.NSMutableOrderedSet.counterpart = "ImmutableSuperclass(Foundation::NSOrderedSet::NSOrderedSet)" +class.NSOrderedSet.counterpart = "MutableSubclass(Foundation.NSOrderedSet.NSMutableOrderedSet)" +class.NSMutableOrderedSet.counterpart = "ImmutableSuperclass(Foundation.NSOrderedSet.NSOrderedSet)" -class.NSIndexSet.counterpart = "MutableSubclass(Foundation::NSIndexSet::NSMutableIndexSet)" -class.NSMutableIndexSet.counterpart = "ImmutableSuperclass(Foundation::NSIndexSet::NSIndexSet)" +class.NSIndexSet.counterpart = "MutableSubclass(Foundation.NSIndexSet.NSMutableIndexSet)" +class.NSMutableIndexSet.counterpart = "ImmutableSuperclass(Foundation.NSIndexSet.NSIndexSet)" -class.NSURLRequest.counterpart = "MutableSubclass(Foundation::NSURLRequest::NSMutableURLRequest)" -class.NSMutableURLRequest.counterpart = "ImmutableSuperclass(Foundation::NSURLRequest::NSURLRequest)" +class.NSURLRequest.counterpart = "MutableSubclass(Foundation.NSURLRequest.NSMutableURLRequest)" +class.NSMutableURLRequest.counterpart = "ImmutableSuperclass(Foundation.NSURLRequest.NSURLRequest)" # NOTE: `NSEnumerator` and subclasses should be interior mutable because # regardless of what kind the items it contains are, the enumerator itself is. diff --git a/framework-crates/objc2-store-kit/translation-config.toml b/framework-crates/objc2-store-kit/translation-config.toml index 902758b93..9040cd741 100644 --- a/framework-crates/objc2-store-kit/translation-config.toml +++ b/framework-crates/objc2-store-kit/translation-config.toml @@ -9,5 +9,5 @@ watchos = "6.2" visionos = "1.0" # Set counterparts -class.SKPayment.counterpart = "MutableSubclass(StoreKit::SKPayment::SKMutablePayment)" -class.SKMutablePayment.counterpart = "ImmutableSuperclass(StoreKit::SKPayment::SKPayment)" +class.SKPayment.counterpart = "MutableSubclass(StoreKit.SKPayment.SKMutablePayment)" +class.SKMutablePayment.counterpart = "ImmutableSuperclass(StoreKit.SKPayment.SKPayment)" diff --git a/framework-crates/objc2-ui-kit/translation-config.toml b/framework-crates/objc2-ui-kit/translation-config.toml index 82c3da208..f9540d6f5 100644 --- a/framework-crates/objc2-ui-kit/translation-config.toml +++ b/framework-crates/objc2-ui-kit/translation-config.toml @@ -31,14 +31,14 @@ static.UIKeyInputF1.skipped = true class.NSTextStorage.skipped-protocols = ["NSCopying", "NSMutableCopying"] # Set counterparts -class.NSParagraphStyle.counterpart = "MutableSubclass(UIKit::NSParagraphStyle::NSMutableParagraphStyle)" -class.NSMutableParagraphStyle.counterpart = "ImmutableSuperclass(UIKit::NSParagraphStyle::NSParagraphStyle)" -class.UIApplicationShortcutItem.counterpart = "MutableSubclass(UIKit::UIApplicationShortcutItem::UIMutableApplicationShortcutItem)" -class.UIMutableApplicationShortcutItem.counterpart = "ImmutableSuperclass(UIKit::UIApplicationShortcutItem::UIApplicationShortcutItem)" -class.UIUserNotificationCategory.counterpart = "MutableSubclass(UIKit::UIUserNotificationSettings::UIMutableUserNotificationCategory)" -class.UIMutableUserNotificationCategory.counterpart = "ImmutableSuperclass(UIKit::UIUserNotificationSettings::UIUserNotificationCategory)" -class.UIUserNotificationAction.counterpart = "MutableSubclass(UIKit::UIUserNotificationSettings::UIMutableUserNotificationAction)" -class.UIMutableUserNotificationAction.counterpart = "ImmutableSuperclass(UIKit::UIUserNotificationSettings::UIUserNotificationAction)" +class.NSParagraphStyle.counterpart = "MutableSubclass(UIKit.NSParagraphStyle.NSMutableParagraphStyle)" +class.NSMutableParagraphStyle.counterpart = "ImmutableSuperclass(UIKit.NSParagraphStyle.NSParagraphStyle)" +class.UIApplicationShortcutItem.counterpart = "MutableSubclass(UIKit.UIApplicationShortcutItem.UIMutableApplicationShortcutItem)" +class.UIMutableApplicationShortcutItem.counterpart = "ImmutableSuperclass(UIKit.UIApplicationShortcutItem.UIApplicationShortcutItem)" +class.UIUserNotificationCategory.counterpart = "MutableSubclass(UIKit.UIUserNotificationSettings.UIMutableUserNotificationCategory)" +class.UIMutableUserNotificationCategory.counterpart = "ImmutableSuperclass(UIKit.UIUserNotificationSettings.UIUserNotificationCategory)" +class.UIUserNotificationAction.counterpart = "MutableSubclass(UIKit.UIUserNotificationSettings.UIMutableUserNotificationAction)" +class.UIMutableUserNotificationAction.counterpart = "ImmutableSuperclass(UIKit.UIUserNotificationSettings.UIUserNotificationAction)" # These subclass a generic struct, and hence the type parameter defaults to # `AnyObject`, which is not PartialEq, Eq nor Hash. diff --git a/framework-crates/objc2-user-notifications/translation-config.toml b/framework-crates/objc2-user-notifications/translation-config.toml index 8c8175a91..d884c7a92 100644 --- a/framework-crates/objc2-user-notifications/translation-config.toml +++ b/framework-crates/objc2-user-notifications/translation-config.toml @@ -10,8 +10,8 @@ visionos = "1.0" external.CLRegion.module = "CoreLocation.CLRegion" -class.UNNotificationContent.counterpart = "MutableSubclass(UserNotifications::UNNotificationContent::UNMutableNotificationContent)" -class.UNMutableNotificationContent.counterpart = "ImmutableSuperclass(UserNotifications::UNNotificationContent::UNNotificationContent)" +class.UNNotificationContent.counterpart = "MutableSubclass(UserNotifications.UNNotificationContent.UNMutableNotificationContent)" +class.UNMutableNotificationContent.counterpart = "ImmutableSuperclass(UserNotifications.UNNotificationContent.UNNotificationContent)" # Requires `INSendMessageIntent` from the Intents framework class.UNNotificationAttributedMessageContext.methods."contextWithSendMessageIntent:attributedContent:".skipped = true