CodeGenerator

@objcMembers public final class CodeGenerator: NSObject

Helper for generating code from a workspace.

This object is essentially a wrapper of a non-UI web version of Blockly, which generates workspace code via JavaScript. For more information on how this works, see:

https://developers.google.com/blockly/installation/code-generators

Note

  • This object must be instantiated on the main thread, as it internally instantiates a WKWebView object (which has to be done on the main thread).
  • This object is not thread-safe.
  • Users should not use this class directly and instead should use CodeGeneratorService, which handles these problems.
    • Possible states for the code generator

      Declaration

      Swift

      public enum State: Int
    • List of core Blockly JS dependencies

      Declaration

      Swift

      public let jsCoreDependencies: [BundledFile]
    • The name of the JS object that generates code (e.g. ‘Blockly.Python’)

      Declaration

      Swift

      public let jsGeneratorObject: String
    • List of block generator JS files (e.g. [‘python_compressed.js’])

      Declaration

      Swift

      public let jsBlockGeneratorFiles: [BundledFile]
    • List of JSON files containing block definitions

      Declaration

      Swift

      public let jsonBlockDefinitionFiles: [BundledFile]
    • The current state of the code generator

      Declaration

      Swift

      public fileprivate(set) var state: State = .initialized