| # WARNING: This file is machine generated by fidlgen. |
| |
| 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()["test.handles"] |
| add_ir_path(_ir_path) |
| |
| |
| @dataclass |
| class FdfHandles: |
| fdf_channel_handle: int |
| client_end_driver: int |
| server_end_driver: int |
| |
| __fidl_kind__ = "struct" |
| __fidl_type__ = "FdfHandles" |
| __fidl_raw_type__ = "test.handles/FdfHandles" |
| |
| # TODO(https://fxbug.dev/394421154): We should probably remove this method when we |
| # start making breaking changes. |
| def __getitem__(self, item: str): # type: ignore |
| if not isinstance(item, str): |
| raise TypeError("Subscripted item must be a string") |
| return getattr(self, item) |
| |
| # TODO(https://fxbug.dev/394421154): We should probably return a more readable type. |
| def encode(self) -> tuple[bytes, list[tuple[int, int, int, int, int]]]: |
| return encode_fidl_object( |
| self, "test.handles", "test.handles/FdfHandles" |
| ) |
| |
| # TODO(https://fxbug.dev/394421154): Assigning None (incorrectly) to each type is a consequence |
| # of needing to support creation of a "default object" before decoding. |
| @classmethod |
| def make_default(cls) -> typing.Self: |
| return cls( |
| **{ |
| "fdf_channel_handle": None, # type: ignore[arg-type,unused-ignore] |
| "client_end_driver": None, # type: ignore[arg-type,unused-ignore] |
| "server_end_driver": None, # type: ignore[arg-type,unused-ignore] |
| } |
| ) |
| |
| |
| @dataclass |
| class Handles: |
| plain_handle: int |
| bti_handle: int |
| channel_handle: int |
| clock_handle: int |
| debuglog_handle: int |
| event_handle: int |
| eventpair_handle: int |
| exception_handle: int |
| fifo_handle: int |
| guest_handle: int |
| interrupt_handle: int |
| iob_handle: int |
| iommu_handle: int |
| job_handle: int |
| msi_handle: int |
| pager_handle: int |
| pmt_handle: int |
| port_handle: int |
| process_handle: int |
| profile_handle: int |
| resource_handle: int |
| socket_handle: int |
| stream_handle: int |
| suspendtoken_handle: int |
| thread_handle: int |
| timer_handle: int |
| vcpu_handle: int |
| vmar_handle: int |
| vmo_handle: int |
| rights_handle: int |
| aliased_plain_handle_field: int |
| aliased_subtype_handle_field: int |
| aliased_rights_handle_field: int |
| some_protocol: int |
| request_some_protocol: int |
| |
| __fidl_kind__ = "struct" |
| __fidl_type__ = "Handles" |
| __fidl_raw_type__ = "test.handles/Handles" |
| |
| # TODO(https://fxbug.dev/394421154): We should probably remove this method when we |
| # start making breaking changes. |
| def __getitem__(self, item: str): # type: ignore |
| if not isinstance(item, str): |
| raise TypeError("Subscripted item must be a string") |
| return getattr(self, item) |
| |
| # TODO(https://fxbug.dev/394421154): We should probably return a more readable type. |
| def encode(self) -> tuple[bytes, list[tuple[int, int, int, int, int]]]: |
| return encode_fidl_object(self, "test.handles", "test.handles/Handles") |
| |
| # TODO(https://fxbug.dev/394421154): Assigning None (incorrectly) to each type is a consequence |
| # of needing to support creation of a "default object" before decoding. |
| @classmethod |
| def make_default(cls) -> typing.Self: |
| return cls( |
| **{ |
| "plain_handle": None, # type: ignore[arg-type,unused-ignore] |
| "bti_handle": None, # type: ignore[arg-type,unused-ignore] |
| "channel_handle": None, # type: ignore[arg-type,unused-ignore] |
| "clock_handle": None, # type: ignore[arg-type,unused-ignore] |
| "debuglog_handle": None, # type: ignore[arg-type,unused-ignore] |
| "event_handle": None, # type: ignore[arg-type,unused-ignore] |
| "eventpair_handle": None, # type: ignore[arg-type,unused-ignore] |
| "exception_handle": None, # type: ignore[arg-type,unused-ignore] |
| "fifo_handle": None, # type: ignore[arg-type,unused-ignore] |
| "guest_handle": None, # type: ignore[arg-type,unused-ignore] |
| "interrupt_handle": None, # type: ignore[arg-type,unused-ignore] |
| "iob_handle": None, # type: ignore[arg-type,unused-ignore] |
| "iommu_handle": None, # type: ignore[arg-type,unused-ignore] |
| "job_handle": None, # type: ignore[arg-type,unused-ignore] |
| "msi_handle": None, # type: ignore[arg-type,unused-ignore] |
| "pager_handle": None, # type: ignore[arg-type,unused-ignore] |
| "pmt_handle": None, # type: ignore[arg-type,unused-ignore] |
| "port_handle": None, # type: ignore[arg-type,unused-ignore] |
| "process_handle": None, # type: ignore[arg-type,unused-ignore] |
| "profile_handle": None, # type: ignore[arg-type,unused-ignore] |
| "resource_handle": None, # type: ignore[arg-type,unused-ignore] |
| "socket_handle": None, # type: ignore[arg-type,unused-ignore] |
| "stream_handle": None, # type: ignore[arg-type,unused-ignore] |
| "suspendtoken_handle": None, # type: ignore[arg-type,unused-ignore] |
| "thread_handle": None, # type: ignore[arg-type,unused-ignore] |
| "timer_handle": None, # type: ignore[arg-type,unused-ignore] |
| "vcpu_handle": None, # type: ignore[arg-type,unused-ignore] |
| "vmar_handle": None, # type: ignore[arg-type,unused-ignore] |
| "vmo_handle": None, # type: ignore[arg-type,unused-ignore] |
| "rights_handle": None, # type: ignore[arg-type,unused-ignore] |
| "aliased_plain_handle_field": None, # type: ignore[arg-type,unused-ignore] |
| "aliased_subtype_handle_field": None, # type: ignore[arg-type,unused-ignore] |
| "aliased_rights_handle_field": None, # type: ignore[arg-type,unused-ignore] |
| "some_protocol": None, # type: ignore[arg-type,unused-ignore] |
| "request_some_protocol": None, # type: ignore[arg-type,unused-ignore] |
| } |
| ) |
| |
| |
| # Generated aliases |
| AliasedPlainHandle = int |
| AliasedRightsHandle = int |
| AliasedSubtypeHandle = int |
| |
| |
| from fidl._client import EventHandlerBase, FidlClient |
| from fidl._server import ServerBase |
| from fidl._fidl_common import ( |
| DomainError, |
| FrameworkError, |
| MethodInfo, |
| FidlProtocolMarker, |
| normalize_identifier, |
| ) |
| |
| from abc import abstractmethod, ABC |
| |
| |
| class SomeProtocolServer(ServerBase, ABC): |
| __fidl_kind__ = "server" |
| library = "test.handles" |
| method_map: typing.Dict[int, MethodInfo] = {} |
| |
| @staticmethod |
| def construct_response_object( |
| response_ident: str, response_obj: typing.Any |
| ) -> typing.Any: |
| import fidl._construct |
| |
| return fidl._construct.construct_response_object( |
| response_ident, response_obj |
| ) |
| |
| |
| class SomeProtocolClient(FidlClient): |
| __fidl_kind__ = "client" |
| library = "test.handles" |
| |
| @staticmethod |
| def construct_response_object( |
| response_ident: str, response_obj: typing.Any |
| ) -> typing.Any: |
| import fidl._construct |
| |
| return fidl._construct.construct_response_object( |
| response_ident, response_obj |
| ) |
| |
| |
| class SomeProtocolEventHandler(EventHandlerBase, ABC): |
| __fidl_kind__ = "event_handler" |
| library = "test.handles" |
| method_map: typing.Dict[int, MethodInfo] = {} |
| |
| @staticmethod |
| def construct_response_object( |
| response_ident: str, response_obj: typing.Any |
| ) -> typing.Any: |
| import fidl._construct |
| |
| return fidl._construct.construct_response_object( |
| response_ident, response_obj |
| ) |
| |
| |
| SomeProtocolMarker = FidlProtocolMarker( |
| "(nondiscoverable) test.handles/SomeProtocol" |
| ) |