Class JavaScriptWriter


  • public class JavaScriptWriter
    extends java.lang.Object
    Write JavaScipt glue code.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static java.lang.String JAVA_SCRIPT_CONTENT
      annotation attribute for the JavaScript content
      private java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.util.function.Function<java.lang.String,​java.lang.Object>>> modules  
      private WasmTarget target  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addImport​(java.lang.String module, java.lang.String name, java.util.function.Function<java.lang.String,​java.lang.Object> annotationValues)
      Add an import from a needed function with import annotation.
      void finish()
      Finish the accumulate of imports and write the JavaScript file.
      (package private) void finish​(java.lang.Appendable out)
      Finish the accumulate of imports and write the JavaScript to the Appendable.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • JAVA_SCRIPT_CONTENT

        static final java.lang.String JAVA_SCRIPT_CONTENT
        annotation attribute for the JavaScript content
        See Also:
        Constant Field Values
      • modules

        private java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.util.function.Function<java.lang.String,​java.lang.Object>>> modules
    • Constructor Detail

      • JavaScriptWriter

        public JavaScriptWriter​(WasmTarget target)
        Create a new instance
        Parameters:
        target - the target for the module data.
    • Method Detail

      • addImport

        public void addImport​(java.lang.String module,
                              java.lang.String name,
                              java.util.function.Function<java.lang.String,​java.lang.Object> annotationValues)
        Add an import from a needed function with import annotation.
        Parameters:
        module - the module name
        name - the function name
        annotationValues - the other values of the annotation
      • finish

        public void finish()
                    throws java.io.IOException
        Finish the accumulate of imports and write the JavaScript file.
        Throws:
        java.io.IOException - if any I/O error occur
      • finish

        void finish​(java.lang.Appendable out)
             throws java.io.IOException
        Finish the accumulate of imports and write the JavaScript to the Appendable.
        Parameters:
        out - the target for the script
        Throws:
        java.io.IOException - if any I/O error occur