Browse Source

Fix settings_size vs byte_size confusion in gen_settings.py.

pull/3/head
Jakob Stoklund Olesen 8 years ago
parent
commit
f18041b56c
  1. 4
      meta/gen_settings.py

4
meta/gen_settings.py

@ -231,7 +231,7 @@ def gen_constructor(sgrp, settings_size, byte_size, parent, fmt):
'pub fn new({}) -> Flags {{'.format(args), '}'):
fmt.line('let bvec = builder.finish("{}");'.format(sgrp.name))
fmt.line('let mut bytes = [0; {}];'.format(byte_size))
fmt.line('assert_eq!(bytes.len(), {});'.format(settings_size))
fmt.line('assert_eq!(bvec.len(), {});'.format(settings_size))
with fmt.indented(
'for (i, b) in bvec.into_iter().enumerate() {', '}'):
fmt.line('bytes[i] = b;')
@ -268,7 +268,7 @@ def gen_group(sgrp, fmt):
fmt.line('#[derive(Clone)]')
fmt.doc_comment('Flags group `{}`.'.format(sgrp.name))
with fmt.indented('pub struct Flags {', '}'):
fmt.line('bytes: [u8; {}],'.format(settings_size))
fmt.line('bytes: [u8; {}],'.format(byte_size))
gen_constructor(sgrp, settings_size, byte_size, None, fmt)
gen_enum_types(sgrp, fmt)

Loading…
Cancel
Save