| 1 |
"""Custom ctypes types and structures for GLib interoperability.""" |
| 2 |
|
| 3 |
from __future__ import annotations |
| 4 |
|
| 5 |
from ctypes import Structure, c_char_p, c_int, c_uint |
| 6 |
from typing import ClassVar |
| 7 |
|
| 8 |
|
| 9 |
class gchar_p(c_char_p): # noqa: N801 |
| 10 |
"""Represents a pointer to a null-terminated string.""" |
| 11 |
|
| 12 |
# represents "[const] gchar*" |
| 13 |
|
| 14 |
|
| 15 |
class gint(c_int): # noqa: N801 |
| 16 |
"""Represents a signed integer.""" |
| 17 |
|
| 18 |
|
| 19 |
class guint(c_uint): # noqa: N801 |
| 20 |
"""Represents a unsigned integer.""" |
| 21 |
|
| 22 |
|
| 23 |
class guint32(c_uint): # noqa: N801 |
| 24 |
"""Represents a 32-bit unsigned integer.""" |
| 25 |
|
| 26 |
|
| 27 |
class GQuark(guint32): |
| 28 |
"""Represents a GQuark, which is a unique identifier for a string.""" |
| 29 |
|
| 30 |
|
| 31 |
class GError(Structure): |
| 32 |
"""Structure representing a GError.""" |
| 33 |
|
| 34 |
_fields_: ClassVar[list[tuple]] = [ |
| 35 |
("DOMAIN", GQuark), |
| 36 |
("code", gint), |
| 37 |
("message", gchar_p), |
| 38 |
] |