From 63c979ff928d60e8f28c544b091c252b9164bf65 Mon Sep 17 00:00:00 2001 From: Ganesh Viswanathan Date: Wed, 18 Dec 2019 21:17:27 -0600 Subject: [PATCH] Fix #158 - array size with division --- nimterop/grammar.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nimterop/grammar.nim b/nimterop/grammar.nim index 16e1b91..9f50ba4 100644 --- a/nimterop/grammar.nim +++ b/nimterop/grammar.nim @@ -332,8 +332,11 @@ proc initGrammar(): Grammar = fname = nimState.getIdentifier(nimState.data[i].val, nskField, nname) if i+1 < nimState.data.len-fend and nimState.data[i+1].name in gEnumVals: - let + # Struct field is an array where size is an expression + var flen = nimState.getNimExpression(nimState.data[i+1].val) + if "/" in flen: + flen = &"({flen}).int" nimState.typeStr &= &"{nimState.getComments()}\n {fname}*: {aptr}array[{flen}, {getPtrType(fptr&ftyp)}]" i += 2 elif i+1 < nimState.data.len-fend and nimState.data[i+1].name == "bitfield_clause":