| {{/* |
| // Copyright 2025 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| */}} |
| {{- define "GenerateSourceFile" -}} |
| # WARNING: This file is machine generated by fidlgen. |
| {{/* |
| // The type of each generated identifier will be forward referenced. The future |
| // annotations feature prevents needing to use string literals for those |
| // references. |
| */}} |
| from __future__ import annotations |
| |
| from dataclasses import dataclass |
| from fidl_codec import add_ir_path, encode_fidl_object |
| import sys |
| import typing |
| import enum |
| |
| import fidl |
| from fidl._ir import get_fidl_ir_map |
| _ir_path = get_fidl_ir_map()["{{ .Name }}"] |
| add_ir_path(_ir_path) |
| |
| {{ range .PythonExternalModules -}} |
| import {{ . }} |
| {{ end }} |
| |
| {{ range .PythonUnsupportedTypes }} |
| class {{ .PythonName }}: |
| def __init__(self, *args: list[typing.Any], _unsupported: fidl.Unsupported, **kwargs: dict[str, typing.Any]) -> None: |
| raise NotImplementedError( |
| """ |
| {{ .Identifier }} not supported. |
| {{ range .Message }} |
| {{ . | escapeQuotes | trimSpace }} |
| {{- end }} |
| """) |
| {{ end }} |
| |
| |
| {{ range .PythonStructs }} |
| {{- template "StructDeclaration" . -}} |
| {{ end -}} |
| |
| |
| {{ range .PythonTables }} |
| {{- template "TableDeclaration" . -}} |
| {{ end -}} |
| |
| |
| {{ range .PythonUnions }} |
| {{- template "UnionDeclaration" . -}} |
| {{ end -}} |
| |
| |
| {{ range .PythonEnums }} |
| {{- template "EnumDeclaration" . -}} |
| {{ end -}} |
| |
| |
| {{ range .PythonBits }} |
| {{- template "BitsDeclaration" . -}} |
| {{ end -}} |
| |
| |
| {{- if .PythonConsts }} |
| # Generated constants |
| {{ end -}} |
| {{ range .PythonConsts -}} |
| {{ .PythonName }}: {{ .PythonType.PythonName }} = {{ .PythonValue }} |
| {{ end }} |
| |
| {{- if .PythonAliases }} |
| # Generated aliases |
| {{ end -}} |
| {{- range .PythonAliases -}} |
| {{.PythonName }} = {{ .PythonAliasedName }} |
| {{ end }} |
| |
| {{ range .PythonProtocols }} |
| {{- template "ProtocolDeclaration" . -}} |
| {{ end -}} |
| {{ end }} |