-
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.
support generics with defaulted args
- Loading branch information
Showing
11 changed files
with
272 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
typedef int16_t Foo_i16; | ||
|
||
typedef int32_t Foo_i32; | ||
|
||
typedef struct { | ||
Foo_i32 f; | ||
uint32_t p; | ||
} Bar_i32__u32; | ||
|
||
typedef int64_t Foo_i64; | ||
|
||
typedef Foo_i64 Baz_i64; | ||
|
||
void foo_root(Foo_i16 f, Bar_i32__u32 b, Baz_i64 z); |
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 @@ | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
typedef int16_t Foo_i16; | ||
|
||
typedef int32_t Foo_i32; | ||
|
||
typedef struct { | ||
Foo_i32 f; | ||
uint32_t p; | ||
} Bar_i32__u32; | ||
|
||
typedef int64_t Foo_i64; | ||
|
||
typedef Foo_i64 Baz_i64; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif // __cplusplus | ||
|
||
void foo_root(Foo_i16 f, Bar_i32__u32 b, Baz_i64 z); | ||
|
||
#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,23 @@ | ||
#include <cstdarg> | ||
#include <cstdint> | ||
#include <cstdlib> | ||
#include <ostream> | ||
#include <new> | ||
|
||
template<typename T, typename P = void> | ||
using Foo = T; | ||
|
||
template<typename T, typename P> | ||
struct Bar { | ||
Foo<T> f; | ||
P p; | ||
}; | ||
|
||
template<typename T> | ||
using Baz = Foo<T>; | ||
|
||
extern "C" { | ||
|
||
void foo_root(Foo<int16_t> f, Bar<int32_t, uint32_t> b, Baz<int64_t> z); | ||
|
||
} // 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,21 @@ | ||
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 int16_t Foo_i16; | ||
|
||
ctypedef int32_t Foo_i32; | ||
|
||
ctypedef struct Bar_i32__u32: | ||
Foo_i32 f; | ||
uint32_t p; | ||
|
||
ctypedef int64_t Foo_i64; | ||
|
||
ctypedef Foo_i64 Baz_i64; | ||
|
||
void foo_root(Foo_i16 f, Bar_i32__u32 b, Baz_i64 z); |
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,19 @@ | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
typedef int16_t Foo_i16; | ||
|
||
typedef int32_t Foo_i32; | ||
|
||
typedef struct Bar_i32__u32 { | ||
Foo_i32 f; | ||
uint32_t p; | ||
} Bar_i32__u32; | ||
|
||
typedef int64_t Foo_i64; | ||
|
||
typedef Foo_i64 Baz_i64; | ||
|
||
void foo_root(Foo_i16 f, struct Bar_i32__u32 b, Baz_i64 z); |
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 @@ | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
typedef int16_t Foo_i16; | ||
|
||
typedef int32_t Foo_i32; | ||
|
||
typedef struct Bar_i32__u32 { | ||
Foo_i32 f; | ||
uint32_t p; | ||
} Bar_i32__u32; | ||
|
||
typedef int64_t Foo_i64; | ||
|
||
typedef Foo_i64 Baz_i64; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif // __cplusplus | ||
|
||
void foo_root(Foo_i16 f, struct Bar_i32__u32 b, Baz_i64 z); | ||
|
||
#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,19 @@ | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
typedef int16_t Foo_i16; | ||
|
||
typedef int32_t Foo_i32; | ||
|
||
struct Bar_i32__u32 { | ||
Foo_i32 f; | ||
uint32_t p; | ||
}; | ||
|
||
typedef int64_t Foo_i64; | ||
|
||
typedef Foo_i64 Baz_i64; | ||
|
||
void foo_root(Foo_i16 f, struct Bar_i32__u32 b, Baz_i64 z); |
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 @@ | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
typedef int16_t Foo_i16; | ||
|
||
typedef int32_t Foo_i32; | ||
|
||
struct Bar_i32__u32 { | ||
Foo_i32 f; | ||
uint32_t p; | ||
}; | ||
|
||
typedef int64_t Foo_i64; | ||
|
||
typedef Foo_i64 Baz_i64; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif // __cplusplus | ||
|
||
void foo_root(Foo_i16 f, struct Bar_i32__u32 b, Baz_i64 z); | ||
|
||
#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,21 @@ | ||
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 int16_t Foo_i16; | ||
|
||
ctypedef int32_t Foo_i32; | ||
|
||
cdef struct Bar_i32__u32: | ||
Foo_i32 f; | ||
uint32_t p; | ||
|
||
ctypedef int64_t Foo_i64; | ||
|
||
ctypedef Foo_i64 Baz_i64; | ||
|
||
void foo_root(Foo_i16 f, Bar_i32__u32 b, Baz_i64 z); |
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,16 @@ | ||
#[repr(transparent)] | ||
pub struct Foo<T, P = c_void> { | ||
field: T, | ||
_phantom: std::marker::PhantomData<P>, | ||
} | ||
|
||
#[repr(C)] | ||
pub struct Bar<T, P> { | ||
f: Foo<T>, | ||
p: P, | ||
} | ||
|
||
pub type Baz<T> = Foo<T>; | ||
|
||
#[no_mangle] | ||
pub extern "C" fn foo_root(f: Foo<i16>, b: Bar<i32, u32>, z: Baz<i64>) {} |