forked from mozilla/cbindgen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cbindgen already simplifies `MaybeUninit<T>` and `ManuallyDrop<T>` to `T`. This adds `Pin<T>` as well.
- Loading branch information
Showing
13 changed files
with
308 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#if 0 | ||
''' ' | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
template <typename T> | ||
using Pin = T; | ||
template <typename T> | ||
using Box = T*; | ||
#endif | ||
|
||
#if 0 | ||
' ''' | ||
#endif | ||
|
||
|
||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
typedef struct PinTest { | ||
int32_t *pinned_box; | ||
int32_t *pinned_ref; | ||
} PinTest; | ||
|
||
void root(int32_t *s, struct PinTest p); |
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,35 @@ | ||
#if 0 | ||
''' ' | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
template <typename T> | ||
using Pin = T; | ||
template <typename T> | ||
using Box = T*; | ||
#endif | ||
|
||
#if 0 | ||
' ''' | ||
#endif | ||
|
||
|
||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
typedef struct PinTest { | ||
int32_t *pinned_box; | ||
int32_t *pinned_ref; | ||
} PinTest; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif // __cplusplus | ||
|
||
void root(int32_t *s, struct PinTest p); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif // __cplusplus |
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,27 @@ | ||
#if 0 | ||
''' ' | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
template <typename T> | ||
using Pin = T; | ||
template <typename T> | ||
using Box = T*; | ||
#endif | ||
|
||
#if 0 | ||
' ''' | ||
#endif | ||
|
||
|
||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
typedef struct { | ||
int32_t *pinned_box; | ||
int32_t *pinned_ref; | ||
} PinTest; | ||
|
||
void root(int32_t *s, PinTest p); |
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,35 @@ | ||
#if 0 | ||
''' ' | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
template <typename T> | ||
using Pin = T; | ||
template <typename T> | ||
using Box = T*; | ||
#endif | ||
|
||
#if 0 | ||
' ''' | ||
#endif | ||
|
||
|
||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
typedef struct { | ||
int32_t *pinned_box; | ||
int32_t *pinned_ref; | ||
} PinTest; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif // __cplusplus | ||
|
||
void root(int32_t *s, PinTest p); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif // __cplusplus |
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,32 @@ | ||
#if 0 | ||
''' ' | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
template <typename T> | ||
using Pin = T; | ||
template <typename T> | ||
using Box = T*; | ||
#endif | ||
|
||
#if 0 | ||
' ''' | ||
#endif | ||
|
||
|
||
#include <cstdarg> | ||
#include <cstdint> | ||
#include <cstdlib> | ||
#include <ostream> | ||
#include <new> | ||
|
||
struct PinTest { | ||
Pin<Box<int32_t>> pinned_box; | ||
Pin<int32_t*> pinned_ref; | ||
}; | ||
|
||
extern "C" { | ||
|
||
void root(Pin<int32_t*> s, PinTest p); | ||
|
||
} // 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,29 @@ | ||
#if 0 | ||
''' ' | ||
#endif | ||
#ifdef __cplusplus | ||
template <typename T> | ||
using Pin = T; | ||
template <typename T> | ||
using Box = T*; | ||
#endif | ||
#if 0 | ||
' ''' | ||
#endif | ||
|
||
|
||
from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t | ||
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t | ||
cdef extern from *: | ||
ctypedef bint bool | ||
ctypedef struct va_list | ||
|
||
cdef extern from *: | ||
|
||
ctypedef struct PinTest: | ||
int32_t *pinned_box; | ||
int32_t *pinned_ref; | ||
|
||
void root(int32_t *s, PinTest p); |
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,27 @@ | ||
#if 0 | ||
''' ' | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
template <typename T> | ||
using Pin = T; | ||
template <typename T> | ||
using Box = T*; | ||
#endif | ||
|
||
#if 0 | ||
' ''' | ||
#endif | ||
|
||
|
||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
struct PinTest { | ||
int32_t *pinned_box; | ||
int32_t *pinned_ref; | ||
}; | ||
|
||
void root(int32_t *s, struct PinTest p); |
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,35 @@ | ||
#if 0 | ||
''' ' | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
template <typename T> | ||
using Pin = T; | ||
template <typename T> | ||
using Box = T*; | ||
#endif | ||
|
||
#if 0 | ||
' ''' | ||
#endif | ||
|
||
|
||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
struct PinTest { | ||
int32_t *pinned_box; | ||
int32_t *pinned_ref; | ||
}; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif // __cplusplus | ||
|
||
void root(int32_t *s, struct PinTest p); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif // __cplusplus |
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 @@ | ||
#if 0 | ||
''' ' | ||
#endif | ||
#ifdef __cplusplus | ||
template <typename T> | ||
using Pin = T; | ||
template <typename T> | ||
using Box = T*; | ||
#endif | ||
#if 0 | ||
' ''' | ||
#endif | ||
|
||
|
||
from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t | ||
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t | ||
cdef extern from *: | ||
ctypedef bint bool | ||
ctypedef struct va_list | ||
|
||
cdef extern from *: | ||
|
||
cdef struct PinTest: | ||
int32_t *pinned_box; | ||
int32_t *pinned_ref; | ||
|
||
void root(int32_t *s, PinTest p); |
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,8 @@ | ||
#[repr(C)] | ||
struct PinTest { | ||
pinned_box: Pin<Box<i32>>, | ||
pinned_ref: Pin<&mut i32> | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn root(s: Pin<&mut i32>, p: PinTest) {} |
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,21 @@ | ||
header = """ | ||
#if 0 | ||
''' ' | ||
#endif | ||
#ifdef __cplusplus | ||
template <typename T> | ||
using Pin = T; | ||
template <typename T> | ||
using Box = T*; | ||
#endif | ||
#if 0 | ||
' ''' | ||
#endif | ||
""" | ||
[export] | ||
exclude = [ | ||
"Pin", | ||
"Box" | ||
] |