-
Notifications
You must be signed in to change notification settings - Fork 698
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate opaque blobs for uses of partially specialized templates
This adds `TypeKind::Opaque` which signifies that we do not understand anything about the given type and that we should just generate an opaque blob based on the type's layout. It explicitly uses the opaque type kind for partially specialized templates.
- Loading branch information
Showing
6 changed files
with
150 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
tests/expectations/tests/partial-specialization-and-inheritance.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* automatically generated by rust-bindgen */ | ||
|
||
|
||
#![allow(non_snake_case)] | ||
|
||
|
||
#[repr(C)] | ||
#[derive(Debug, Default, Copy, Clone)] | ||
pub struct Base { | ||
pub _address: u8, | ||
} | ||
#[repr(C)] | ||
#[derive(Debug, Default, Copy, Clone)] | ||
pub struct Derived { | ||
pub b: bool, | ||
} | ||
#[test] | ||
fn __bindgen_test_layout__bindgen_ty_id_20_instantiation_14() { | ||
assert_eq!(::std::mem::size_of::<[u32; 2usize]>() , 8usize , concat ! ( | ||
"Size of template specialization: " , stringify ! ( | ||
[u32; 2usize] ) )); | ||
assert_eq!(::std::mem::align_of::<[u32; 2usize]>() , 4usize , concat ! ( | ||
"Alignment of template specialization: " , stringify ! ( | ||
[u32; 2usize] ) )); | ||
} | ||
#[repr(C)] | ||
#[derive(Debug, Default, Copy)] | ||
pub struct Usage { | ||
pub _address: u8, | ||
} | ||
extern "C" { | ||
#[link_name = "_ZN5Usage13static_memberE"] | ||
pub static mut Usage_static_member: [u32; 2usize]; | ||
} | ||
#[test] | ||
fn bindgen_test_layout_Usage() { | ||
assert_eq!(::std::mem::size_of::<Usage>() , 1usize , concat ! ( | ||
"Size of: " , stringify ! ( Usage ) )); | ||
assert_eq! (::std::mem::align_of::<Usage>() , 1usize , concat ! ( | ||
"Alignment of " , stringify ! ( Usage ) )); | ||
} | ||
impl Clone for Usage { | ||
fn clone(&self) -> Self { *self } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// This was originally a test case generated by creducing errors in SpiderMonkey | ||
// bindings generation. I've tried to make it understandable by giving more | ||
// meaningful names to everything, and a couple comments. | ||
// | ||
// We don't support partial template specialization, but we *should* | ||
// successfully parse this header, and generate bindings for it, but the usage | ||
// of the partial template specialization should result in opaque blobs. | ||
|
||
// A base class providing a method. | ||
template <typename T> | ||
class Base { | ||
public: | ||
void some_method(T, T); | ||
}; | ||
|
||
// A template with a default representation. | ||
template <typename U> | ||
class Derived { | ||
bool b; | ||
}; | ||
|
||
// A partial specialization for pointers. Note that this should have a different | ||
// and larger layout than the template it is specializing. | ||
template <typename U> | ||
class Derived<U*> : public Base<U*> { | ||
int x; | ||
int y; | ||
}; | ||
|
||
// A struct that uses the partial specialization and method from the partial | ||
// specialization's base class. | ||
struct Usage { | ||
Usage() { | ||
static_member.some_method(this, this); | ||
} | ||
|
||
static Derived<Usage*> static_member; | ||
}; |