Esempio n. 1
0
def generate_binding_cpp(config, outputprefix, webidlfile):
    """
    |config| Is the configuration object.
    |outputprefix| is a prefix to use for the header guards and filename.
    """

    filename = outputprefix + ".cpp"
    root = CGBindingRoot(config, outputprefix, webidlfile)
    if replaceFileIfChanged(filename, root.define()):
        print "Generating binding implementation: %s" % (filename)
Esempio n. 2
0
def generate_binding_rs(config, outputprefix, webidlfile):
    """
    |config| Is the configuration object.
    |outputprefix| is a prefix to use for the header guards and filename.
    """

    filename = outputprefix + ".rs"
    root = CGBindingRoot(config, outputprefix, webidlfile)
    if replaceFileIfChanged(filename, root.define()):
        print "Generating binding implementation: %s" % (filename)
Esempio n. 3
0
def main():
    os.chdir(os.path.join(os.path.dirname(__file__)))
    sys.path[0:0] = ["./parser", "./ply"]

    css_properties_json, out_dir = sys.argv[1:]
    doc_servo = "../../../../../target/doc/servo"
    webidls_dir = "../../webidls"
    config_file = "Bindings.conf"

    import WebIDL
    from Configuration import Configuration
    from CodegenRust import CGBindingRoot

    parser = WebIDL.Parser(make_dir(os.path.join(out_dir, "cache")))
    webidls = [
        name for name in os.listdir(webidls_dir) if name.endswith(".webidl")
    ]
    for webidl in webidls:
        filename = os.path.join(webidls_dir, webidl)
        with open(filename, "rb") as f:
            parser.parse(f.read(), filename)

    add_css_properties_attributes(css_properties_json, parser)
    parser_results = parser.finish()
    config = Configuration(config_file, parser_results)
    make_dir(os.path.join(out_dir, "Bindings"))

    for name, filename in [
        ("PrototypeList", "PrototypeList.rs"),
        ("RegisterBindings", "RegisterBindings.rs"),
        ("InterfaceObjectMap", "InterfaceObjectMap.rs"),
        ("InterfaceObjectMapData", "InterfaceObjectMapData.json"),
        ("InterfaceTypes", "InterfaceTypes.rs"),
        ("InheritTypes", "InheritTypes.rs"),
        ("Bindings", "Bindings/mod.rs"),
        ("UnionTypes", "UnionTypes.rs"),
    ]:
        generate(config, name, os.path.join(out_dir, filename))
    make_dir(doc_servo)
    generate(config, "SupportedDomApis", os.path.join(doc_servo, "apis.html"))

    for webidl in webidls:
        filename = os.path.join(webidls_dir, webidl)
        prefix = "Bindings/%sBinding" % webidl[:-len(".webidl")]
        module = CGBindingRoot(config, prefix, filename).define()
        if module:
            with open(os.path.join(out_dir, prefix + ".rs"), "wb") as f:
                f.write(module.encode("utf-8"))
Esempio n. 4
0
def generate_binding_rs(config, outputprefix, webidlfile):
    """
    |config| Is the configuration object.
    |outputprefix| is a prefix to use for the header guards and filename.
    """

    filename = outputprefix + ".rs"
    module = CGBindingRoot(config, outputprefix, webidlfile).define()
    if not module:
        print "Skipping empty module: %s" % (filename)
    elif replaceFileIfChanged(filename, module):
        print "Generating binding implementation: %s" % (filename)