1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:57:47 +00:00

LibGfx: Unbreak building with Python 3.9

Unbreaks building with macOS 13 system python, and is less code too.
No behavior change.
This commit is contained in:
Nico Weber 2023-11-28 09:54:03 +09:00 committed by Tim Flynn
parent 1b3223dd9e
commit b2302ed23f

View file

@ -9,7 +9,7 @@ import re
from enum import Enum from enum import Enum
from collections import namedtuple from collections import namedtuple
from pathlib import Path from pathlib import Path
from typing import List, Type from typing import List, Optional, Type
class TIFFType(Enum): class TIFFType(Enum):
@ -73,7 +73,7 @@ LICENSE = R"""/*
*/""" */"""
def export_enum_to_cpp(e: Type[Enum], special_name: str | None = None) -> str: def export_enum_to_cpp(e: Type[Enum], special_name: Optional[str] = None) -> str:
output = f'enum class {special_name if special_name else e.__name__} {{\n' output = f'enum class {special_name if special_name else e.__name__} {{\n'
for entry in e: for entry in e:
@ -94,13 +94,11 @@ def tiff_type_to_cpp(t: TIFFType, without_promotion: bool = False) -> str:
# Note that the Value<> type doesn't include u16 for this reason # Note that the Value<> type doesn't include u16 for this reason
if not without_promotion: if not without_promotion:
t = promote_type(t) t = promote_type(t)
match t: if t == TIFFType.UnsignedShort:
case TIFFType.UnsignedShort: return 'u16'
return 'u16' if t == TIFFType.UnsignedLong:
case TIFFType.UnsignedLong: return 'u32'
return 'u32' raise RuntimeError(f'Type "{t}" not recognized, please update tiff_type_to_read_only_cpp()')
case _:
raise RuntimeError(f'Type "{t}" not recognized, please update tiff_type_to_read_only_cpp()')
def export_promoter() -> str: def export_promoter() -> str: