MCPcopy Index your code
hub / github.com/ZeroIntensity/pointers.py / wrapper

Function wrapper

src/pointers/custom_binding.py:27–56  ·  view source on GitHub ↗
(*args: P.args, **kwargs: P.kwargs)

Source from the content-addressed store, hash-verified

25 def decorator(func: Callable[P, T]) -> Callable[P, T]:
26 @wraps(func)
27 def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
28 if kwargs:
29 raise ValueError(
30 "keyword arguments are not allowed when calling C functions" # noqa
31 )
32
33 restype = dll_func.restype
34
35 if (
36 struct
37 and (not issubclass(restype, ctypes.Structure)) # type: ignore
38 and (not (restype or int).__name__.startswith("LP_"))
39 ):
40 raise ValueError("restype must be a ctypes structure")
41
42 return binding_base(
43 dll_func,
44 *[
45 # fmt: off
46 i if not isinstance(i, str)
47 else make_string(i)
48 # fmt: on
49 for i in args # type: ignore
50 ],
51 map_extra={
52 dll_func.restype: struct, # type: ignore
53 }
54 if struct
55 else None,
56 )
57
58 return wrapper
59

Callers

nothing calls this directly

Calls 2

binding_baseFunction · 0.85
make_stringFunction · 0.85

Tested by

no test coverage detected