parity-wasm icon indicating copy to clipboard operation
parity-wasm copied to clipboard

elements::Section struct hierarchy lacks constructors

Open frehberg opened this issue 7 years ago • 1 comments

The structures in elements/section.rs lack explicit constructor-methods (new-methods) to instantiate them programmatically, for example to extend a list of parsed sections of a module. Sadly, the private members of those structures do not permit to instantiate instances outside of the crate.

The following functions would be helpful: CustomSection::new(name:.., payload:..) -> CustomSection TypeSection::new(types:..) -> TypeSection etc.

All elements derive the Default trait, except the CustomSection. CustomSection should derive the Default trait, so default instances could be created from CustomSection, see https://github.com/paritytech/parity-wasm/pull/169

frehberg avatar Feb 11 '18 21:02 frehberg

Pull-Request #169 has been merged, now it will be possible to instantiate CustomSection the following way:

    let mut custom_section: CustomSection = Default::default();

frehberg avatar Feb 12 '18 11:02 frehberg