Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proc macro proof-of-concept #425

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: '1.60'
toolchain: '1.62'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSRV has to follow winit (which is currently at 1.60)

profile: minimal
override: true
target: x86_64-apple-darwin
Expand Down Expand Up @@ -317,7 +317,7 @@ jobs:
# - lint

env:
ARGS: --no-default-features --features=std,apple
ARGS: --no-default-features --features=std,apple,unstable-proc-macros

steps:
- uses: actions/checkout@v3
Expand Down
93 changes: 93 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 23 additions & 19 deletions crates/header-translator/src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,30 +577,34 @@ impl fmt::Display for Method {

write!(f, "{}", self.availability)?;

if self.is_optional_protocol {
writeln!(f, " #[optional]")?;
}

let id_mm_name = match &self.memory_management {
MemoryManagement::IdCopyOrMutCopy => Some("CopyOrMutCopy"),
MemoryManagement::IdNew => Some("New"),
MemoryManagement::IdInit => Some("Init"),
MemoryManagement::IdOther => Some("Other"),
MemoryManagement::Normal => None,
};
if let Some(id_mm_name) = id_mm_name {
write!(f, " #[method_id(@__retain_semantics {id_mm_name} ")?;
} else {
write!(f, " #[method(")?;
}
let error_trailing = if self.result_type.is_error() { "_" } else { "" };
writeln!(f, "{}{})]", self.selector, error_trailing)?;
writeln!(
f,
r#" #[objc2::method({}sel = "{}"{}{})]"#,
if self.is_optional_protocol {
"optional, "
} else {
""
},
self.selector,
match &self.memory_management {
MemoryManagement::IdCopyOrMutCopy => r#", managed = "CopyOrMutCopy""#,
MemoryManagement::IdNew => r#", managed = "New""#,
MemoryManagement::IdInit => r#", managed = "Init""#,
MemoryManagement::IdOther => r#", managed = "Other""#,
MemoryManagement::Normal => "",
},
if self.result_type.is_error() {
", throws"
} else {
""
},
)?;

//
// Signature
//

write!(f, " ")?;
write!(f, " ")?;
if !self.is_protocol {
write!(f, "pub ")?;
}
Expand Down
Loading