Skip to content

Commit

Permalink
tests: Add a test for mozilla#708
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Aug 24, 2021
1 parent cbd4260 commit 577b041
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 9 deletions.
7 changes: 6 additions & 1 deletion tests/expectations/mangle.both.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
#include <stdint.h>
#include <stdlib.h>

typedef enum Bar {
BarSome,
BarThing,
} Bar;

typedef struct FooU8 {
uint8_t a;
} FooU8;

typedef struct FooU8 Boo;

void root(Boo x);
void root(Boo x, enum Bar y);
7 changes: 6 additions & 1 deletion tests/expectations/mangle.both.compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
#include <stdint.h>
#include <stdlib.h>

typedef enum Bar {
BarSome,
BarThing,
} Bar;

typedef struct FooU8 {
uint8_t a;
} FooU8;
Expand All @@ -13,7 +18,7 @@ typedef struct FooU8 Boo;
extern "C" {
#endif // __cplusplus

void root(Boo x);
void root(Boo x, enum Bar y);

#ifdef __cplusplus
} // extern "C"
Expand Down
7 changes: 6 additions & 1 deletion tests/expectations/mangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
#include <stdint.h>
#include <stdlib.h>

typedef enum {
BarSome,
BarThing,
} Bar;

typedef struct {
uint8_t a;
} FooU8;

typedef FooU8 Boo;

void root(Boo x);
void root(Boo x, Bar y);
7 changes: 6 additions & 1 deletion tests/expectations/mangle.compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
#include <stdint.h>
#include <stdlib.h>

typedef enum {
BarSome,
BarThing,
} Bar;

typedef struct {
uint8_t a;
} FooU8;
Expand All @@ -13,7 +18,7 @@ typedef FooU8 Boo;
extern "C" {
#endif // __cplusplus

void root(Boo x);
void root(Boo x, Bar y);

#ifdef __cplusplus
} // extern "C"
Expand Down
7 changes: 6 additions & 1 deletion tests/expectations/mangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include <ostream>
#include <new>

enum class Bar {
BarSome,
BarThing,
};

template<typename T>
struct Foo {
T a;
Expand All @@ -13,6 +18,6 @@ using Boo = Foo<uint8_t>;

extern "C" {

void root(Boo x);
void root(Boo x, Bar y);

} // extern "C"
6 changes: 5 additions & 1 deletion tests/expectations/mangle.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ cdef extern from *:

cdef extern from *:

ctypedef enum Bar:
BarSome,
BarThing,

ctypedef struct FooU8:
uint8_t a;

ctypedef FooU8 Boo;

void root(Boo x);
void root(Boo x, Bar y);
7 changes: 6 additions & 1 deletion tests/expectations/mangle.tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
#include <stdint.h>
#include <stdlib.h>

enum Bar {
BarSome,
BarThing,
};

struct FooU8 {
uint8_t a;
};

typedef struct FooU8 Boo;

void root(Boo x);
void root(Boo x, enum Bar y);
7 changes: 6 additions & 1 deletion tests/expectations/mangle.tag.compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
#include <stdint.h>
#include <stdlib.h>

enum Bar {
BarSome,
BarThing,
};

struct FooU8 {
uint8_t a;
};
Expand All @@ -13,7 +18,7 @@ typedef struct FooU8 Boo;
extern "C" {
#endif // __cplusplus

void root(Boo x);
void root(Boo x, enum Bar y);

#ifdef __cplusplus
} // extern "C"
Expand Down
6 changes: 5 additions & 1 deletion tests/expectations/mangle.tag.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ cdef extern from *:

cdef extern from *:

cdef enum Bar:
BarSome,
BarThing,

cdef struct FooU8:
uint8_t a;

ctypedef FooU8 Boo;

void root(Boo x);
void root(Boo x, Bar y);
8 changes: 8 additions & 0 deletions tests/rust/mangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ pub struct Foo<T> {

pub type Boo = Foo<u8>;

/// cbindgen:prefix-with-name=true
#[repr(C)]
pub enum Bar {
Some,
Thing,
}

#[no_mangle]
pub extern "C" fn root(
x: Boo,
y: Bar,
) { }

0 comments on commit 577b041

Please sign in to comment.