mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-20 16:26:33 +00:00
Add support for modules to the backend.
This commit is contained in:
@ -19,6 +19,19 @@ pub struct Program {
|
||||
pub structs: Vec<Struct>,
|
||||
/// rust consts
|
||||
pub consts: Vec<Const>,
|
||||
/// rust submodules
|
||||
pub modules: Vec<Module>,
|
||||
}
|
||||
|
||||
/// A rust module
|
||||
///
|
||||
/// This exists to give the ability to namespace js imports.
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
pub struct Module {
|
||||
/// module name
|
||||
pub name: String,
|
||||
/// js -> rust interfaces
|
||||
pub imports: Vec<Import>,
|
||||
}
|
||||
|
||||
/// A rust to js interface. Allows interaction with rust objects/functions
|
||||
@ -227,6 +240,8 @@ impl Program {
|
||||
structs: self.structs.iter().map(|a| a.shared()).collect(),
|
||||
enums: self.enums.iter().map(|a| a.shared()).collect(),
|
||||
imports: self.imports.iter()
|
||||
// add in imports from inside modules
|
||||
.chain(self.modules.iter().flat_map(|m| m.imports.iter()))
|
||||
.map(|a| a.shared())
|
||||
.collect::<Result<_, Diagnostic>>()?,
|
||||
version: shared::version(),
|
||||
|
Reference in New Issue
Block a user