summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-08-10 15:21:03 -0700
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-08-13 23:51:02 -0700
commit620867d42f2c21078c4be6fa8c3057409e7ee2bf (patch)
tree0d5516518934179c5bb214e7268da27ba8541020
parent19e2a44412646b6dada97ff4c89fd527a95bff50 (diff)
Add test for union templates without using template parameters.
-rw-r--r--tests/expectations/union_template.rs86
-rw-r--r--tests/headers/union_template.hpp19
2 files changed, 105 insertions, 0 deletions
diff --git a/tests/expectations/union_template.rs b/tests/expectations/union_template.rs
new file mode 100644
index 00000000..eb6705f0
--- /dev/null
+++ b/tests/expectations/union_template.rs
@@ -0,0 +1,86 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[derive(Copy, Debug)]
+#[repr(C)]
+pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
+impl <T> __BindgenUnionField<T> {
+ #[inline]
+ pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
+ #[inline]
+ pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
+ #[inline]
+ pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
+}
+impl <T> ::std::default::Default for __BindgenUnionField<T> {
+ #[inline]
+ fn default() -> Self { Self::new() }
+}
+impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Struct_NastyStruct<T> {
+ pub mIsSome: bool,
+ pub mStorage: Union_NastyStruct_union_template_hpp_unnamed_1<T>,
+ pub NastyStruct_union_template_hpp_unnamed_2: Union_NastyStruct_union_template_hpp_unnamed_2<T>,
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Union_NastyStruct_union_template_hpp_unnamed_1<T> {
+ pub mFoo: __BindgenUnionField<*mut ::std::os::raw::c_void>,
+ pub mDummy: __BindgenUnionField<::std::os::raw::c_ulong>,
+ pub _bindgen_data_: u64,
+ pub _phantom0: ::std::marker::PhantomData<T>,
+}
+impl <T> Union_NastyStruct_union_template_hpp_unnamed_1<T> {
+ pub unsafe fn mFoo(&mut self) -> *mut *mut ::std::os::raw::c_void {
+ let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
+ ::std::mem::transmute(raw.offset(0))
+ }
+ pub unsafe fn mDummy(&mut self) -> *mut ::std::os::raw::c_ulong {
+ let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
+ ::std::mem::transmute(raw.offset(0))
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Union_NastyStruct_union_template_hpp_unnamed_2<T> {
+ pub wat: __BindgenUnionField<::std::os::raw::c_short>,
+ pub wut: __BindgenUnionField<*mut ::std::os::raw::c_int>,
+ pub _bindgen_data_: u64,
+ pub _phantom0: ::std::marker::PhantomData<T>,
+}
+impl <T> Union_NastyStruct_union_template_hpp_unnamed_2<T> {
+ pub unsafe fn wat(&mut self) -> *mut ::std::os::raw::c_short {
+ let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
+ ::std::mem::transmute(raw.offset(0))
+ }
+ pub unsafe fn wut(&mut self) -> *mut *mut ::std::os::raw::c_int {
+ let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
+ ::std::mem::transmute(raw.offset(0))
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Union_Whatever<T> {
+ pub mTPtr: __BindgenUnionField<*mut ::std::os::raw::c_void>,
+ pub mInt: __BindgenUnionField<::std::os::raw::c_int>,
+ pub _bindgen_data_: u64,
+ pub _phantom0: ::std::marker::PhantomData<T>,
+}
+impl <T> Union_Whatever<T> {
+ pub unsafe fn mTPtr(&mut self) -> *mut *mut ::std::os::raw::c_void {
+ let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
+ ::std::mem::transmute(raw.offset(0))
+ }
+ pub unsafe fn mInt(&mut self) -> *mut ::std::os::raw::c_int {
+ let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
+ ::std::mem::transmute(raw.offset(0))
+ }
+}
diff --git a/tests/headers/union_template.hpp b/tests/headers/union_template.hpp
new file mode 100644
index 00000000..0d0a9bb3
--- /dev/null
+++ b/tests/headers/union_template.hpp
@@ -0,0 +1,19 @@
+template<typename T>
+struct NastyStruct {
+ bool mIsSome;
+ union {
+ void* mFoo;
+ unsigned long mDummy;
+ } mStorage;
+
+ union {
+ short wat;
+ int* wut;
+ };
+};
+
+template<typename T>
+union Whatever {
+ void* mTPtr;
+ int mInt;
+};