mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-11-24 14:42:35 +03:00
parent
f61e12af91
commit
5efde3abe9
@ -415,6 +415,7 @@ impl Program {
|
||||
pub fn shared(&self) -> shared::Program {
|
||||
shared::Program {
|
||||
exports: self.exports.iter().map(|a| a.shared()).collect(),
|
||||
structs: self.structs.iter().map(|a| a.name.as_ref().to_string()).collect(),
|
||||
enums: self.enums.iter().map(|a| a.shared()).collect(),
|
||||
imports: self.imports.iter().map(|a| a.shared()).collect(),
|
||||
version: shared::version(),
|
||||
|
@ -1279,6 +1279,11 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
||||
for e in self.program.enums.iter() {
|
||||
self.generate_enum(e);
|
||||
}
|
||||
for s in self.program.structs.iter() {
|
||||
self.cx.exported_classes
|
||||
.entry(s.clone())
|
||||
.or_insert_with(Default::default);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_export(&mut self, export: &shared::Export) {
|
||||
|
@ -8,6 +8,7 @@ pub struct Program {
|
||||
pub exports: Vec<Export>,
|
||||
pub enums: Vec<Enum>,
|
||||
pub imports: Vec<Import>,
|
||||
pub structs: Vec<String>,
|
||||
pub version: String,
|
||||
pub schema_version: String,
|
||||
}
|
||||
|
@ -367,8 +367,6 @@ fn pass_into_js_as_js_class() {
|
||||
.test();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[test]
|
||||
fn constructors() {
|
||||
project()
|
||||
@ -445,3 +443,33 @@ fn constructors() {
|
||||
"#)
|
||||
.test();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_structs() {
|
||||
project()
|
||||
.debug(false)
|
||||
.file("src/lib.rs", r#"
|
||||
#![feature(proc_macro, wasm_custom_section, wasm_import_module)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub struct MissingClass {}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub struct Other {}
|
||||
|
||||
#[wasm_bindgen]
|
||||
impl Other { pub fn return_a_value() -> MissingClass { MissingClass {} } }
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
import { Other } from "./out";
|
||||
|
||||
export function test() {
|
||||
Other.return_a_value();
|
||||
}
|
||||
"#)
|
||||
.test();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user