Skip to content

Commit

Permalink
Properly rename QuartzCore to CoreAnimation
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jan 10, 2023
1 parent 39fda4f commit 0274b5f
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 95 deletions.
17 changes: 17 additions & 0 deletions crates/header-translator/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,26 @@ pub struct Config {
pub libraries: HashMap<String, LibraryData>,
}

impl Config {
pub fn get_library_alias(&self, library_name: String) -> String {
self.libraries
.iter()
.find_map(|(n, data)| {
if let Some(name) = &data.name {
if n == &library_name {
return Some(name.clone());
}
}
None
})
.unwrap_or_else(|| library_name)
}
}

#[derive(Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct LibraryData {
pub name: Option<String>,
pub imports: Vec<String>,
}

Expand Down
10 changes: 7 additions & 3 deletions crates/header-translator/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ pub struct ItemIdentifier<N = String> {

impl<N> ItemIdentifier<N> {
pub fn with_name(name: N, entity: &Entity<'_>, context: &Context<'_>) -> Self {
let (library, file_name) = context
let (library_name, file_name) = context
.get_library_and_file_name(entity)
.expect("ItemIdentifier get library and file");

Self {
name,
library,
library: context.get_library_alias(library_name),
file_name,
}
}
Expand Down Expand Up @@ -111,7 +112,10 @@ impl ItemIdentifier {
ItemIdentifierPath(self)
}

pub fn path_in_relation_to<'a, T>(&'a self, other: &'a ItemIdentifier<T>) -> impl fmt::Display + 'a {
pub fn path_in_relation_to<'a, T>(
&'a self,
other: &'a ItemIdentifier<T>,
) -> impl fmt::Display + 'a {
struct ItemIdentifierPathInRelationTo<'a, T>(&'a ItemIdentifier, &'a ItemIdentifier<T>);

impl<T> fmt::Display for ItemIdentifierPathInRelationTo<'_, T> {
Expand Down
4 changes: 2 additions & 2 deletions crates/header-translator/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Output {
);
}

pub fn cargo_features(&self, _config: &Config) -> BTreeMap<String, Vec<String>> {
pub fn cargo_features(&self, config: &Config) -> BTreeMap<String, Vec<String>> {
let mut features = BTreeMap::new();

// for (_, library) in &config.libraries {
Expand Down Expand Up @@ -72,7 +72,7 @@ impl Output {
}

let _ = features.insert(
format!("{library_name}_all"),
format!("{}_all", config.get_library_alias(library_name.clone())),
library_features.into_iter().collect::<Vec<_>>(),
);
}
Expand Down
14 changes: 12 additions & 2 deletions crates/header-translator/src/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -932,10 +932,20 @@ impl fmt::Display for Stmt {
// Using generics in here is not technically correct, but
// should work for our use-cases.
if let Some((superclass, generics)) = iter.next() {
write!(f, "{}{}", superclass.path_in_relation_to(&id), GenericTyHelper(&generics))?;
write!(
f,
"{}{}",
superclass.path_in_relation_to(&id),
GenericTyHelper(&generics)
)?;
}
for (superclass, generics) in iter {
write!(f, ", {}{}", superclass.path_in_relation_to(&id), GenericTyHelper(&generics))?;
write!(
f,
", {}{}",
superclass.path_in_relation_to(&id),
GenericTyHelper(&generics)
)?;
}
writeln!(f, ")]")?;
}
Expand Down
1 change: 1 addition & 0 deletions crates/header-translator/translation-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
imports = ["Foundation"]

[library.QuartzCore]
name = "CoreAnimation"
imports = ["CoreAnimation", "Foundation"]

[library.Metal]
Expand Down
174 changes: 87 additions & 87 deletions crates/icrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ unstable-private = []

AppKit = ["Foundation", "CoreData"]
AuthenticationServices = ["Foundation"]
CoreAnimation = ["Foundation", "QuartzCore_all"]
CoreAnimation = ["Foundation", "CoreAnimation_all"]
CoreData = ["Foundation"]
Foundation = ["objective-c", "block"]
Metal = ["Foundation"]
Expand All @@ -106,8 +106,8 @@ Metal = ["Foundation"]
unstable-frameworks-all = ["unstable-frameworks-ios", "unstable-frameworks-macos-12"]
unstable-frameworks-gnustep = ["AppKit_all", "Foundation_all"]
unstable-frameworks-gnustep-32bit = ["Foundation_all"]
unstable-frameworks-ios = ["AuthenticationServices_all", "CoreData_all", "QuartzCore_all", "Foundation_all", "Metal_all"]
unstable-frameworks-macos-10-7 = ["AppKit_all", "QuartzCore_all", "CoreData_all", "Foundation_all"]
unstable-frameworks-ios = ["AuthenticationServices_all", "CoreData_all", "CoreAnimation_all", "Foundation_all", "Metal_all"]
unstable-frameworks-macos-10-7 = ["AppKit_all", "CoreAnimation_all", "CoreData_all", "Foundation_all"]
unstable-frameworks-macos-10-13 = ["unstable-frameworks-macos-10-7"]
unstable-frameworks-macos-11 = ["unstable-frameworks-macos-10-13", "AuthenticationServices_all", "Metal_all"]
unstable-frameworks-macos-12 = ["unstable-frameworks-macos-11"]
Expand Down Expand Up @@ -1086,6 +1086,90 @@ AuthenticationServices_all = [
"AuthenticationServices_ASWebAuthenticationSessionRequest",
"AuthenticationServices_ASWebAuthenticationSessionWebBrowserSessionManager",
]
CoreAnimation_CAAnimation = []
CoreAnimation_CAAnimationGroup = [
"CoreAnimation_CAAnimation",
]
CoreAnimation_CABasicAnimation = [
"CoreAnimation_CAPropertyAnimation",
]
CoreAnimation_CAConstraint = []
CoreAnimation_CAConstraintLayoutManager = []
CoreAnimation_CADisplayLink = []
CoreAnimation_CAEDRMetadata = []
CoreAnimation_CAEmitterCell = []
CoreAnimation_CAEmitterLayer = [
"CoreAnimation_CALayer",
]
CoreAnimation_CAGradientLayer = [
"CoreAnimation_CALayer",
]
CoreAnimation_CAKeyframeAnimation = [
"CoreAnimation_CAPropertyAnimation",
]
CoreAnimation_CALayer = []
CoreAnimation_CAMediaTimingFunction = []
CoreAnimation_CAPropertyAnimation = [
"CoreAnimation_CAAnimation",
]
CoreAnimation_CARemoteLayerClient = []
CoreAnimation_CARemoteLayerServer = []
CoreAnimation_CARenderer = []
CoreAnimation_CAReplicatorLayer = [
"CoreAnimation_CALayer",
]
CoreAnimation_CAScrollLayer = [
"CoreAnimation_CALayer",
]
CoreAnimation_CAShapeLayer = [
"CoreAnimation_CALayer",
]
CoreAnimation_CASpringAnimation = [
"CoreAnimation_CABasicAnimation",
]
CoreAnimation_CATextLayer = [
"CoreAnimation_CALayer",
]
CoreAnimation_CATiledLayer = [
"CoreAnimation_CALayer",
]
CoreAnimation_CATransaction = []
CoreAnimation_CATransformLayer = [
"CoreAnimation_CALayer",
]
CoreAnimation_CATransition = [
"CoreAnimation_CAAnimation",
]
CoreAnimation_CAValueFunction = []
CoreAnimation_all = [
"CoreAnimation_CAAnimation",
"CoreAnimation_CAAnimationGroup",
"CoreAnimation_CABasicAnimation",
"CoreAnimation_CAConstraint",
"CoreAnimation_CAConstraintLayoutManager",
"CoreAnimation_CADisplayLink",
"CoreAnimation_CAEDRMetadata",
"CoreAnimation_CAEmitterCell",
"CoreAnimation_CAEmitterLayer",
"CoreAnimation_CAGradientLayer",
"CoreAnimation_CAKeyframeAnimation",
"CoreAnimation_CALayer",
"CoreAnimation_CAMediaTimingFunction",
"CoreAnimation_CAPropertyAnimation",
"CoreAnimation_CARemoteLayerClient",
"CoreAnimation_CARemoteLayerServer",
"CoreAnimation_CARenderer",
"CoreAnimation_CAReplicatorLayer",
"CoreAnimation_CAScrollLayer",
"CoreAnimation_CAShapeLayer",
"CoreAnimation_CASpringAnimation",
"CoreAnimation_CATextLayer",
"CoreAnimation_CATiledLayer",
"CoreAnimation_CATransaction",
"CoreAnimation_CATransformLayer",
"CoreAnimation_CATransition",
"CoreAnimation_CAValueFunction",
]
CoreData_NSAsynchronousFetchRequest = [
"CoreData_NSPersistentStoreRequest",
]
Expand Down Expand Up @@ -2218,87 +2302,3 @@ Metal_all = [
"Metal_MTLVertexDescriptor",
"Metal_MTLVisibleFunctionTableDescriptor",
]
QuartzCore_CAAnimation = []
QuartzCore_CAAnimationGroup = [
"QuartzCore_CAAnimation",
]
QuartzCore_CABasicAnimation = [
"QuartzCore_CAPropertyAnimation",
]
QuartzCore_CAConstraint = []
QuartzCore_CAConstraintLayoutManager = []
QuartzCore_CADisplayLink = []
QuartzCore_CAEDRMetadata = []
QuartzCore_CAEmitterCell = []
QuartzCore_CAEmitterLayer = [
"QuartzCore_CALayer",
]
QuartzCore_CAGradientLayer = [
"QuartzCore_CALayer",
]
QuartzCore_CAKeyframeAnimation = [
"QuartzCore_CAPropertyAnimation",
]
QuartzCore_CALayer = []
QuartzCore_CAMediaTimingFunction = []
QuartzCore_CAPropertyAnimation = [
"QuartzCore_CAAnimation",
]
QuartzCore_CARemoteLayerClient = []
QuartzCore_CARemoteLayerServer = []
QuartzCore_CARenderer = []
QuartzCore_CAReplicatorLayer = [
"QuartzCore_CALayer",
]
QuartzCore_CAScrollLayer = [
"QuartzCore_CALayer",
]
QuartzCore_CAShapeLayer = [
"QuartzCore_CALayer",
]
QuartzCore_CASpringAnimation = [
"QuartzCore_CABasicAnimation",
]
QuartzCore_CATextLayer = [
"QuartzCore_CALayer",
]
QuartzCore_CATiledLayer = [
"QuartzCore_CALayer",
]
QuartzCore_CATransaction = []
QuartzCore_CATransformLayer = [
"QuartzCore_CALayer",
]
QuartzCore_CATransition = [
"QuartzCore_CAAnimation",
]
QuartzCore_CAValueFunction = []
QuartzCore_all = [
"QuartzCore_CAAnimation",
"QuartzCore_CAAnimationGroup",
"QuartzCore_CABasicAnimation",
"QuartzCore_CAConstraint",
"QuartzCore_CAConstraintLayoutManager",
"QuartzCore_CADisplayLink",
"QuartzCore_CAEDRMetadata",
"QuartzCore_CAEmitterCell",
"QuartzCore_CAEmitterLayer",
"QuartzCore_CAGradientLayer",
"QuartzCore_CAKeyframeAnimation",
"QuartzCore_CALayer",
"QuartzCore_CAMediaTimingFunction",
"QuartzCore_CAPropertyAnimation",
"QuartzCore_CARemoteLayerClient",
"QuartzCore_CARemoteLayerServer",
"QuartzCore_CARenderer",
"QuartzCore_CAReplicatorLayer",
"QuartzCore_CAScrollLayer",
"QuartzCore_CAShapeLayer",
"QuartzCore_CASpringAnimation",
"QuartzCore_CATextLayer",
"QuartzCore_CATiledLayer",
"QuartzCore_CATransaction",
"QuartzCore_CATransformLayer",
"QuartzCore_CATransition",
"QuartzCore_CAValueFunction",
]
2 changes: 1 addition & 1 deletion crates/icrate/src/generated

0 comments on commit 0274b5f

Please sign in to comment.