blob: 8298af7b85704a61ae263763291106e136b7914f [file]
{{/*
// 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
import sys
import typing
import enum
import fidl
from fidl._client import EventHandlerBase, FidlClient # type: ignore[unused-ignore,unused-import]
from fidl._server import ServerBase # type: ignore[unused-ignore,unused-import]
from fidl._fidl_common import DomainError, FrameworkError, MethodInfo, FidlProtocolMarker, normalize_identifier # type: ignore[unused-ignore,unused-import]
from abc import abstractmethod, ABC # type: ignore[unused-ignore,unused-import]
import collections.abc # type: ignore[unused-ignore,unused-import]
{{ range .PythonExternalModules -}}
import {{ . }}
{{ end }}
_UNDEFINED: typing.Any = object()
{{ 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 }}
""")
def _encode(self, encoder: fidl.Encoder, _offset: int) -> None:
raise NotImplementedError("{{ .Identifier }} is unsupported")
@classmethod
def _decode(cls, decoder: fidl.Decoder, _offset: int) -> typing.Self:
raise NotImplementedError("{{ .Identifier }} is unsupported")
{{ 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 }}