Coverage for linuxpy/codegen/gpio.py: 0%
20 statements
« prev ^ index » next coverage.py v7.6.8, created at 2025-05-27 13:54 +0200
« prev ^ index » next coverage.py v7.6.8, created at 2025-05-27 13:54 +0200
1#
2# This file is part of the linuxpy project
3#
4# Copyright (c) 2024 Tiago Coutinho
5# Distributed under the GPLv3 license. See LICENSE for more info.
7import pathlib
9from linuxpy.codegen.base import CEnum, run
11HEADERS = [
12 "/usr/include/linux/gpio.h",
13]
16TEMPLATE = """\
17#
18# This file is part of the linuxpy project
19#
20# Copyright (c) 2024 Tiago Coutinho
21# Distributed under the GPLv3 license. See LICENSE for more info.
23# This file has been generated by {name}
24# Date: {date}
25# System: {system}
26# Release: {release}
27# Version: {version}
29import enum
31from linuxpy.ioctl import IOR as _IOR, IOW as _IOW, IOWR as _IOWR
32from linuxpy.ctypes import u8, u16, u32, cuint, cint, cchar, culonglong
33from linuxpy.ctypes import Struct, Union, POINTER, cvoidp
36MAX_LINES = 64
37MAX_ATTRS = 10
40{enums_body}
43{structs_body}
46{iocs_body}"""
49class IOC(CEnum):
50 def __init__(self):
51 def filter(name, value):
52 return name.endswith("_IOCTL")
54 super().__init__("IOC", ["GPIO_GET_", "GPIO_V2_"], filter=filter)
56 def add_item(self, name, value):
57 name = name.removesuffix("_IOCTL")
58 return super().add_item(name, value)
61# macros from #define statements
62MACRO_ENUMS = [
63 IOC(),
64]
67this_dir = pathlib.Path(__file__).parent
70def decode_name(name: str) -> str:
71 return name.removeprefix("gpio_v2_").removeprefix("gpio_")
74def main(output=this_dir.parent / "gpio" / "raw.py"):
75 run(__name__, HEADERS, TEMPLATE, MACRO_ENUMS, output=output, decode_enum_name=decode_name)
78if __name__ == "__main__":
79 main()