Skip to content

Commit

Permalink
support non-mut statics with Option<&T>
Browse files Browse the repository at this point in the history
  • Loading branch information
gnzlbg committed Oct 30, 2018
1 parent e17d4ae commit 31cae7d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,11 @@ impl<'a> Generator<'a> {
return &{c_name};
}}
"#,
mutbl = if mutbl { "" } else { "const " },
mutbl = if mutbl || c_ty.contains("const") {
""
} else {
"const "
},
ty = c_ty,
name = name,
c_name = c_name
Expand Down
5 changes: 4 additions & 1 deletion testcrate/src/t1.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,8 @@ int32_t T1_arr4[2][3] = {{0, 0, 0}, {0, 0, 0}};
int32_t T1_arr5[1][2][3] = {{{0, 0, 0}, {0, 0, 0}}};

int32_t T1_arr42[1][2][3] = {{{0, 0, 0}, {0, 0, 0}}};
const int32_t* T1_opt_ref = NULL;
const int16_t* T1_sref = (void*)(1337);

const int32_t* T1_mut_opt_ref = NULL;
int32_t* T1_mut_opt_mut_ref = NULL;
const int32_t* T1_const_opt_const_ref = NULL;
5 changes: 4 additions & 1 deletion testcrate/src/t1.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ extern int32_t T1_arr5[1][2][3];

extern int32_t T1_arr42[1][2][3];

extern const int32_t* T1_opt_ref;
extern const int16_t* T1_sref;

extern const int32_t* T1_mut_opt_ref;
extern int32_t* T1_mut_opt_mut_ref;
extern const int32_t* T1_const_opt_const_ref;

struct Q {
uint8_t* q0;
uint8_t** q1;
Expand Down
5 changes: 4 additions & 1 deletion testcrate/src/t1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ extern "C" {
#[link_name = "T1_arr42"]
pub static mut T1_arr6: [[[i32; 3]; 2]; 1];

pub static mut T1_opt_ref: Option<&'static i32>;
pub static mut T1_sref: &'static i16;

pub static mut T1_mut_opt_ref: Option<&'static i32>;
pub static mut T1_mut_opt_mut_ref: Option<&'static mut i32>;
pub static T1_const_opt_const_ref: Option<&'static i32>;
}

#[repr(C)]
Expand Down

0 comments on commit 31cae7d

Please sign in to comment.