Add tests for parser fix
The tests are based on https://github.com/vmx/cbindgen-expand-dep-bug
This commit is contained in:
committed by
Emilio Cobos Álvarez
parent
175d3e40ed
commit
7f3b8f4dcd
@@ -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
|
||||
@@ -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);
|
||||
@@ -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
|
||||
@@ -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"
|
||||
@@ -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
|
||||
Generated
+13
@@ -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",
|
||||
]
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "expand-dep"
|
||||
version = "0.1.0"
|
||||
authors = ["cbindgen"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
dep = { path = "dep" }
|
||||
@@ -0,0 +1,6 @@
|
||||
[parse]
|
||||
parse_deps = true
|
||||
include = ["dep"]
|
||||
|
||||
[parse.expand]
|
||||
crates = ["expand-dep"]
|
||||
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "dep"
|
||||
version = "0.1.0"
|
||||
authors = ["cbindgen"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
@@ -0,0 +1,5 @@
|
||||
#[repr(C)]
|
||||
pub struct dep_struct {
|
||||
pub x: u32,
|
||||
pub y: f64,
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user