| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
15 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,10 +2,13 @@ from typing import Any, Callable, TypeVar | |||
| 2 | 2 | ||
| 3 | 3 | _T = TypeVar("_T") | |
| 4 | 4 | ||
| 5 | + | ||
| 5 | 6 | def add_ref(obj: Any) -> None: ... | |
| 6 | 7 | def remove_ref(obj: Any) -> None: ... | |
| 7 | 8 | def force_set_attr(typ: type[Any], key: str, value: Any) -> None: ... | |
| 8 | 9 | def set_ref(obj: Any, count: int) -> None: ... | |
| 10 | + | ||
| 11 | + | ||
| 9 | 12 | def handle( | |
| 10 | 13 | func: Callable[..., _T], | |
| 11 | 14 | args: tuple[Any, ...] | None = None, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,20 +7,37 @@ | |||
| 7 | 7 | from ._utils import force_set_attr | |
| 8 | 8 | from .api_bindings import * | |
| 9 | 9 | from .base_pointers import ( | |
| 10 | - BaseAllocatedPointer, BaseCPointer, BaseObjectPointer, BasePointer, | ||
| 11 | - BasicPointer, Dereferencable, IterDereferencable, Sized, Typed | ||
| 10 | + BaseAllocatedPointer, | ||
| 11 | + BaseCPointer, | ||
| 12 | + BaseObjectPointer, | ||
| 13 | + BasePointer, | ||
| 14 | + BasicPointer, | ||
| 15 | + Dereferencable, | ||
| 16 | + IterDereferencable, | ||
| 17 | + Sized, | ||
| 18 | + Typed, | ||
| 12 | 19 | ) | |
| 13 | 20 | from .bindings import * | |
| 14 | 21 | from .c_pointer import ( | |
| 15 | - TypedCPointer, VoidPointer, array, cast, to_c_ptr, to_struct_ptr, to_voidp | ||
| 22 | + TypedCPointer, | ||
| 23 | + VoidPointer, | ||
| 24 | + array, | ||
| 25 | + cast, | ||
| 26 | + to_c_ptr, | ||
| 27 | + to_struct_ptr, | ||
| 28 | + to_voidp, | ||
| 16 | 29 | ) | |
| 17 | 30 | from .calloc import AllocatedArrayPointer, calloc | |
| 18 | 31 | from .custom_binding import binding, binds | |
| 19 | 32 | from .decay import decay, decay_annotated, decay_wrapped | |
| 20 | 33 | from .exceptions import ( | |
| 21 | - AllocationError, DereferenceError, FreedMemoryError, | ||
| 22 | - InvalidBindingParameter, InvalidSizeError, NullPointerError, | ||
| 23 | - SegmentViolation | ||
| 34 | + AllocationError, | ||
| 35 | + DereferenceError, | ||
| 36 | + FreedMemoryError, | ||
| 37 | + InvalidBindingParameter, | ||
| 38 | + InvalidSizeError, | ||
| 39 | + NullPointerError, | ||
| 40 | + SegmentViolation, | ||
| 24 | 41 | ) | |
| 25 | 42 | from .magic import _ | |
| 26 | 43 | from .malloc import AllocatedPointer, free, malloc, realloc | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,6 @@ | |||
| 1 | 1 | import ctypes | |
| 2 | 2 | from ctypes.util import find_library | |
| 3 | - from platform import system | ||
| 4 | - | ||
| 5 | - platforms = { | ||
| 6 | - "linux": "libc.so.6", | ||
| 7 | - "darwin": "libc.dylib", | ||
| 8 | - "windows": "msvcrt", | ||
| 9 | - } | ||
| 3 | + from sys import platform | ||
| 10 | 4 | ||
| 11 | 5 | __all__ = ( | |
| 12 | 6 | "c_malloc", | |
@@ -20,7 +14,16 @@ | |||
| 20 | 14 | "ldiv_t", | |
| 21 | 15 | ) | |
| 22 | 16 | ||
| 23 | - dll = ctypes.CDLL(platforms.get(system().lower()) or find_library("c")) | ||
| 17 | + _c_library_name: str | ||
| 18 | + | ||
| 19 | + if platform in ("win32", "cygwin"): | ||
| 20 | + _c_library_name = "msvcrt" | ||
| 21 | + elif platform == "darwin": | ||
| 22 | + _c_library_name = "libc.dylib" | ||
| 23 | + else: | ||
| 24 | + _c_library_name = find_library("c") or "libc.so.6" | ||
| 25 | + | ||
| 26 | + dll = ctypes.CDLL(_c_library_name) | ||
| 24 | 27 | ||
| 25 | 28 | ||
| 26 | 29 | class tm(ctypes.Structure): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments