Add tests for parser fix

The tests are based on https://github.com/vmx/cbindgen-expand-dep-bug
This commit is contained in:
Volker Mische
2019-09-20 16:18:52 +02:00
committed by Emilio Cobos Álvarez
parent 175d3e40ed
commit 7f3b8f4dcd
13 changed files with 150 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
typedef struct dep_struct {
uint32_t x;
double y;
} dep_struct;
uint32_t get_x(const dep_struct *dep_struct);
@@ -0,0 +1,19 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
typedef struct dep_struct {
uint32_t x;
double y;
} dep_struct;
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
uint32_t get_x(const dep_struct *dep_struct);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
+11
View File
@@ -0,0 +1,11 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
typedef struct {
uint32_t x;
double y;
} dep_struct;
uint32_t get_x(const dep_struct *dep_struct);
+19
View File
@@ -0,0 +1,19 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
typedef struct {
uint32_t x;
double y;
} dep_struct;
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
uint32_t get_x(const dep_struct *dep_struct);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
+15
View File
@@ -0,0 +1,15 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <new>
struct dep_struct {
uint32_t x;
double y;
};
extern "C" {
uint32_t get_x(const dep_struct *dep_struct);
} // extern "C"
+11
View File
@@ -0,0 +1,11 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
struct dep_struct {
uint32_t x;
double y;
};
uint32_t get_x(const struct dep_struct *dep_struct);
@@ -0,0 +1,19 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
struct dep_struct {
uint32_t x;
double y;
};
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
uint32_t get_x(const struct dep_struct *dep_struct);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
+13
View File
@@ -0,0 +1,13 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "dep"
version = "0.1.0"
[[package]]
name = "expand-dep"
version = "0.1.0"
dependencies = [
"dep 0.1.0",
]
+8
View File
@@ -0,0 +1,8 @@
[package]
name = "expand-dep"
version = "0.1.0"
authors = ["cbindgen"]
edition = "2018"
[dependencies]
dep = { path = "dep" }
+6
View File
@@ -0,0 +1,6 @@
[parse]
parse_deps = true
include = ["dep"]
[parse.expand]
crates = ["expand-dep"]
+7
View File
@@ -0,0 +1,7 @@
[package]
name = "dep"
version = "0.1.0"
authors = ["cbindgen"]
edition = "2018"
[dependencies]
+5
View File
@@ -0,0 +1,5 @@
#[repr(C)]
pub struct dep_struct {
pub x: u32,
pub y: f64,
}
+6
View File
@@ -0,0 +1,6 @@
use dep::dep_struct;
#[no_mangle]
pub unsafe extern "C" fn get_x(dep_struct: *const dep_struct) -> u32 {
dep_struct.read().x
}