Skip to content

Commit a625c5d

Browse files
adetaylorlightsofapollo
authored andcommitted
Distinguish references from pointers.
Using a custom attribute.
1 parent 8d236ad commit a625c5d

File tree

3 files changed

+260
-123
lines changed

3 files changed

+260
-123
lines changed

src/codegen/error.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ pub enum Error {
1111
/// definition that is too difficult for us to understand (like a partial
1212
/// template specialization).
1313
InstantiationOfOpaqueType,
14+
15+
/// Type was a reference not a pointer, but we had nowhere to record that fact.
16+
ReferenceButCouldNotRecord,
1417
}
1518

1619
impl fmt::Display for Error {
@@ -23,6 +26,9 @@ impl fmt::Display for Error {
2326
"Instantiation of opaque template type or partial template \
2427
specialization"
2528
}
29+
Error::ReferenceButCouldNotRecord => {
30+
"Type was a reference in a context where we only expected other types"
31+
}
2632
})
2733
}
2834
}

src/codegen/helpers.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ pub mod attributes {
7474
#[bindgen_original_name(#name)]
7575
}
7676
}
77+
78+
pub fn ret_type_reference() -> TokenStream {
79+
quote! {
80+
#[bindgen_ret_type_reference]
81+
}
82+
}
83+
84+
pub fn arg_type_reference(arg_name: &Ident) -> TokenStream {
85+
quote! {
86+
#[bindgen_arg_type_reference(#arg_name)]
87+
}
88+
}
7789
}
7890

7991
/// Generates a proper type for a field or type with a given `Layout`, that is,

0 commit comments

Comments
 (0)