Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
660 B
8
Indexable

def cpc_lib_function(library):
    def outer(fn):
        name = "CPC_" + fn.__name__
        return_type = fn.__annotations__.pop('return', None)
        parameter_types = tuple(fn.__annotations__.values())
        fn.__annotations__["return"] = return_type

        f = getattr(library, name)
        f.argtypes = parameter_types
        f.restype = return_type


        def wrapper(*args, **kwargs): # overwrites length: ctypes.POINTER(ctypes.c_int)
            f(*args, *kwargs.values())

        return wrapper

    return outer


@cpc_lib_function(dll_library)
def CreateChannelListJSON(length: ctypes.POINTER(ctypes.c_int)) -> ctypes.c_char_p:
    ...