-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for
#[repr(transparent)]
- Loading branch information
1 parent
090b815
commit 0e2d977
Showing
8 changed files
with
183 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
|
||
typedef struct DummyStruct DummyStruct; | ||
|
||
typedef DummyStruct TransparentComplexWrappingStructTuple; | ||
|
||
typedef uint32_t TransparentPrimitiveWrappingStructTuple; | ||
|
||
typedef DummyStruct TransparentComplexWrappingStructure; | ||
|
||
typedef uint32_t TransparentPrimitiveWrappingStructure; | ||
|
||
typedef DummyStruct TransparentComplexWrapper_i32; | ||
|
||
typedef uint32_t TransparentPrimitiveWrapper_i32; | ||
|
||
void root(TransparentComplexWrappingStructTuple a, | ||
TransparentPrimitiveWrappingStructTuple b, | ||
TransparentComplexWrappingStructure c, | ||
TransparentPrimitiveWrappingStructure d, | ||
TransparentComplexWrapper_i32 e, | ||
TransparentPrimitiveWrapper_i32 f); |
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,24 @@ | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
|
||
struct DummyStruct; | ||
|
||
typedef struct DummyStruct TransparentComplexWrappingStructTuple; | ||
|
||
typedef uint32_t TransparentPrimitiveWrappingStructTuple; | ||
|
||
typedef struct DummyStruct TransparentComplexWrappingStructure; | ||
|
||
typedef uint32_t TransparentPrimitiveWrappingStructure; | ||
|
||
typedef struct DummyStruct TransparentComplexWrapper_i32; | ||
|
||
typedef uint32_t TransparentPrimitiveWrapper_i32; | ||
|
||
void root(TransparentComplexWrappingStructTuple a, | ||
TransparentPrimitiveWrappingStructTuple b, | ||
TransparentComplexWrappingStructure c, | ||
TransparentPrimitiveWrappingStructure d, | ||
TransparentComplexWrapper_i32 e, | ||
TransparentPrimitiveWrapper_i32 f); |
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,24 @@ | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
|
||
typedef struct DummyStruct DummyStruct; | ||
|
||
typedef DummyStruct TransparentComplexWrappingStructTuple; | ||
|
||
typedef uint32_t TransparentPrimitiveWrappingStructTuple; | ||
|
||
typedef DummyStruct TransparentComplexWrappingStructure; | ||
|
||
typedef uint32_t TransparentPrimitiveWrappingStructure; | ||
|
||
typedef DummyStruct TransparentComplexWrapper_i32; | ||
|
||
typedef uint32_t TransparentPrimitiveWrapper_i32; | ||
|
||
void root(TransparentComplexWrappingStructTuple a, | ||
TransparentPrimitiveWrappingStructTuple b, | ||
TransparentComplexWrappingStructure c, | ||
TransparentPrimitiveWrappingStructure d, | ||
TransparentComplexWrapper_i32 e, | ||
TransparentPrimitiveWrapper_i32 f); |
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,29 @@ | ||
#include <cstdint> | ||
#include <cstdlib> | ||
|
||
struct DummyStruct; | ||
|
||
using TransparentComplexWrappingStructTuple = DummyStruct; | ||
|
||
using TransparentPrimitiveWrappingStructTuple = uint32_t; | ||
|
||
using TransparentComplexWrappingStructure = DummyStruct; | ||
|
||
using TransparentPrimitiveWrappingStructure = uint32_t; | ||
|
||
template<typename T> | ||
using TransparentComplexWrapper = DummyStruct; | ||
|
||
template<typename T> | ||
using TransparentPrimitiveWrapper = uint32_t; | ||
|
||
extern "C" { | ||
|
||
void root(TransparentComplexWrappingStructTuple a, | ||
TransparentPrimitiveWrappingStructTuple b, | ||
TransparentComplexWrappingStructure c, | ||
TransparentPrimitiveWrappingStructure d, | ||
TransparentComplexWrapper<int32_t> e, | ||
TransparentPrimitiveWrapper<int32_t> f); | ||
|
||
} // extern "C" |
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,41 @@ | ||
struct DummyStruct; | ||
|
||
// Transparent struct tuple wrapping a struct. | ||
#[repr(transparent)] | ||
struct TransparentComplexWrappingStructTuple(DummyStruct); | ||
|
||
// Transparent struct tuple wrapping a primitive. | ||
#[repr(transparent)] | ||
struct TransparentPrimitiveWrappingStructTuple(u32); | ||
|
||
// Transparent structure wrapping a struct. | ||
#[repr(transparent)] | ||
struct TransparentComplexWrappingStructure { only_field: DummyStruct } | ||
|
||
// Transparent structure wrapping a primitive. | ||
#[repr(transparent)] | ||
struct TransparentPrimitiveWrappingStructure { only_field: u32 } | ||
|
||
// Transparent struct wrapper with a marker wrapping a struct. | ||
#[repr(transparent)] | ||
struct TransparentComplexWrapper<T> { | ||
only_non_zero_sized_field: DummyStruct, | ||
marker: PhantomData<T>, | ||
} | ||
|
||
// Transparent struct wrapper with a marker wrapping a primitive. | ||
#[repr(transparent)] | ||
struct TransparentPrimitiveWrapper<T> { | ||
only_non_zero_sized_field: u32, | ||
marker: PhantomData<T>, | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn root( | ||
a: TransparentComplexWrappingStructTuple, | ||
b: TransparentPrimitiveWrappingStructTuple, | ||
c: TransparentComplexWrappingStructure, | ||
d: TransparentPrimitiveWrappingStructure, | ||
e: TransparentComplexWrapper<i32>, | ||
f: TransparentPrimitiveWrapper<i32>, | ||
) { } |