|
2 | 2 |
|
3 | 3 | import ctypes |
4 | 4 | from dataclasses import dataclass |
5 | | -from typing import Type, TypeAlias |
6 | 5 |
|
7 | | -from .backend import is_arch_x86 |
| 6 | +from .defines import CType |
8 | 7 |
|
9 | | -CType = Type[ctypes._SimpleCData] |
10 | 8 | _python_bool = bool |
11 | 9 |
|
12 | 10 |
|
@@ -63,31 +61,7 @@ def is_complex_dtype(dtype: Dtype) -> _python_bool: |
63 | 61 | return dtype in {complex64, complex128} |
64 | 62 |
|
65 | 63 |
|
66 | | -c_dim_t = ctypes.c_int if is_arch_x86() else ctypes.c_longlong |
67 | | -ShapeType = tuple[int, ...] |
68 | | - |
69 | | - |
70 | | -class CShape(tuple): |
71 | | - def __new__(cls, *args: int) -> CShape: |
72 | | - cls.original_shape = len(args) |
73 | | - return tuple.__new__(cls, args) |
74 | | - |
75 | | - def __init__(self, x1: int = 1, x2: int = 1, x3: int = 1, x4: int = 1) -> None: |
76 | | - self.x1 = x1 |
77 | | - self.x2 = x2 |
78 | | - self.x3 = x3 |
79 | | - self.x4 = x4 |
80 | | - |
81 | | - def __repr__(self) -> str: |
82 | | - return f"{self.__class__.__name__}{self.x1, self.x2, self.x3, self.x4}" |
83 | | - |
84 | | - @property |
85 | | - def c_array(self): # type: ignore[no-untyped-def] |
86 | | - c_shape = c_dim_t * 4 # ctypes.c_int | ctypes.c_longlong * 4 |
87 | | - return c_shape(c_dim_t(self.x1), c_dim_t(self.x2), c_dim_t(self.x3), c_dim_t(self.x4)) |
88 | | - |
89 | | - |
90 | | -def to_str(c_str: ctypes.c_char_p) -> str: |
| 64 | +def to_str(c_str: ctypes.c_char_p | ctypes.Array[ctypes.c_char]) -> str: |
91 | 65 | return str(c_str.value.decode("utf-8")) # type: ignore[union-attr] |
92 | 66 |
|
93 | 67 |
|
|
0 commit comments