1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:37:35 +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 collections import namedtuple
from pathlib import Path
from typing import List, Type
from typing import List, Optional, Type
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'
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
if not without_promotion:
t = promote_type(t)
match t:
case TIFFType.UnsignedShort:
return 'u16'
case TIFFType.UnsignedLong:
return 'u32'
case _:
raise RuntimeError(f'Type "{t}" not recognized, please update tiff_type_to_read_only_cpp()')
if t == TIFFType.UnsignedShort:
return 'u16'
if t == TIFFType.UnsignedLong:
return 'u32'
raise RuntimeError(f'Type "{t}" not recognized, please update tiff_type_to_read_only_cpp()')
def export_promoter() -> str: