mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
Add compileToBinary() to the public interface
This commit is contained in:
parent
41ef70b2b1
commit
49060e1e87
@ -16,15 +16,18 @@
|
|||||||
package de.inetsoftware.jwebassembly;
|
package de.inetsoftware.jwebassembly;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import de.inetsoftware.classparser.ClassFile;
|
import de.inetsoftware.classparser.ClassFile;
|
||||||
|
import de.inetsoftware.jwebassembly.binary.BinaryModuleWriter;
|
||||||
import de.inetsoftware.jwebassembly.module.ModuleWriter;
|
import de.inetsoftware.jwebassembly.module.ModuleWriter;
|
||||||
import de.inetsoftware.jwebassembly.text.TextModuleWriter;
|
import de.inetsoftware.jwebassembly.text.TextModuleWriter;
|
||||||
|
|
||||||
@ -82,6 +85,35 @@ public class JWebAssembly {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the added files to a WebAssembly module in binary representation.
|
||||||
|
*
|
||||||
|
* @return the module as string
|
||||||
|
* @throws WasmException
|
||||||
|
* if any conversion error occurs
|
||||||
|
*/
|
||||||
|
public byte[] compileToBinary() throws WasmException {
|
||||||
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
|
compileToBinary( output );
|
||||||
|
return output.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert the added files to a WebAssembly module in binary representation.
|
||||||
|
*
|
||||||
|
* @param output
|
||||||
|
* the target for the module data
|
||||||
|
* @throws WasmException
|
||||||
|
* if any conversion error occurs
|
||||||
|
*/
|
||||||
|
public void compileToBinary( OutputStream output ) throws WasmException {
|
||||||
|
try (BinaryModuleWriter writer = new BinaryModuleWriter( output )) {
|
||||||
|
compile( writer );
|
||||||
|
} catch( Exception ex ) {
|
||||||
|
throw WasmException.create( ex );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the added files to a WebAssembly module.
|
* Convert the added files to a WebAssembly module.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user