Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/bindgen/ir/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ impl Type {
// FIXME(#223): This is not quite correct.
"Option" if generic.is_repr_ptr() => Some(generic),
"NonNull" => Some(Type::Ptr(Box::new(generic))),
"Cell" => Some(generic),
_ => None,
}
}
Expand Down
1 change: 1 addition & 0 deletions src/bindgen/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ impl Parse {

add_opaque("String", vec![]);
add_opaque("Box", vec!["T"]);
add_opaque("RefCell", vec!["T"]);
add_opaque("Rc", vec!["T"]);
add_opaque("Arc", vec!["T"]);
add_opaque("Result", vec!["T", "E"]);
Expand Down
14 changes: 14 additions & 0 deletions tests/expectations/both/cell.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

typedef struct NotReprC_RefCell_i32 NotReprC_RefCell_i32;

typedef NotReprC_RefCell_i32 Foo;

typedef struct MyStruct {
int32_t number;
} MyStruct;

void root(const Foo *a, const MyStruct *with_cell);
22 changes: 22 additions & 0 deletions tests/expectations/both/cell.compat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

typedef struct NotReprC_RefCell_i32 NotReprC_RefCell_i32;

typedef NotReprC_RefCell_i32 Foo;

typedef struct MyStruct {
int32_t number;
} MyStruct;

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

void root(const Foo *a, const MyStruct *with_cell);

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
14 changes: 14 additions & 0 deletions tests/expectations/cell.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

typedef struct NotReprC_RefCell_i32 NotReprC_RefCell_i32;

typedef NotReprC_RefCell_i32 Foo;

typedef struct {
int32_t number;
} MyStruct;

void root(const Foo *a, const MyStruct *with_cell);
22 changes: 22 additions & 0 deletions tests/expectations/cell.compat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

typedef struct NotReprC_RefCell_i32 NotReprC_RefCell_i32;

typedef NotReprC_RefCell_i32 Foo;

typedef struct {
int32_t number;
} MyStruct;

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

void root(const Foo *a, const MyStruct *with_cell);

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
22 changes: 22 additions & 0 deletions tests/expectations/cell.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <new>

template<typename T>
struct NotReprC;

template<typename T>
struct RefCell;

using Foo = NotReprC<RefCell<int32_t>>;

struct MyStruct {
int32_t number;
};

extern "C" {

void root(const Foo *a, const MyStruct *with_cell);

} // extern "C"
14 changes: 14 additions & 0 deletions tests/expectations/tag/cell.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

struct NotReprC_RefCell_i32;

typedef struct NotReprC_RefCell_i32 Foo;

struct MyStruct {
int32_t number;
};

void root(const Foo *a, const struct MyStruct *with_cell);
22 changes: 22 additions & 0 deletions tests/expectations/tag/cell.compat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

struct NotReprC_RefCell_i32;

typedef struct NotReprC_RefCell_i32 Foo;

struct MyStruct {
int32_t number;
};

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

void root(const Foo *a, const struct MyStruct *with_cell);

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
11 changes: 11 additions & 0 deletions tests/rust/cell.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#[repr(C)]
pub struct MyStruct {
number: std::cell::Cell<i32>,
}

pub struct NotReprC<T> { inner: T }

pub type Foo = NotReprC<std::cell::RefCell<i32>>;

#[no_mangle]
pub extern "C" fn root(a: &Foo, with_cell: &MyStruct) {}