Skip to content

Commit

Permalink
generator: Apply static-sized array pointer to size containing *
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Nov 23, 2020
1 parent 63718d3 commit 896d577
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1792,9 +1792,11 @@ pub fn derive_setters(

let mutable = if field.is_const { quote!() } else { quote!(mut) };

let set_size_stmt = if array_size.contains("ename:") {
// Should contain the same minus `ename:`-prefixed identifiers
let array_size = field.c_size.as_ref().unwrap();
// Apply some heuristics to determine whether the size is an expression.
// If so, this is a pointer to a piece of memory with statically known size.
let set_size_stmt = if array_size.contains("ename:") || array_size.contains("*") {
// c_size should contain the same minus `ename:`-prefixed identifiers
let array_size = field.c_size.as_ref().unwrap_or(array_size);
let c_size = convert_c_expression(array_size);
let inner_type = field.inner_type_tokens();

Expand Down

0 comments on commit 896d577

Please sign in to comment.