multi_tools/system/dll.py
def DllImport(func: Union[FunctionType, MethodType], file: Union[str, PathLike], type_: type[Dll.AnyDll] = Dll.WinDll):
    """
    Function decorator that implements dll functions
    with custom type hints and documentation.

    This method is similar to the C# method System.Runtime.InteropServices.DllImport().

    Decorated functions must have not declared any body
    and have the name of the wanted dll's function.

    e.g:

    class Msvcrt:
        @staticmethod
        @DllImport("C:/windows/system32/msvcrt.dll")
        def printf(text: bytes, mode: system.optional[int]): ...

    Msvcrt.printf(b'a')

    >>a

    Decorated functions can't take keyword arguments, since
    dll functions never do. To represent optional arguments,
    use system.optional as showed above.

    This syntax is only a user-made type hint for dll functions.

    If you don't need it, please use the 'Dll' class directly.
    """
    dll = Dll(file, type_)
    name = func.__name__
    dll_name = file.split('/')[-1]

    if not hasattr(dll, name):
        # if the function is not found in dll:
        raise AttributeError("Dll \"{0}\" has no function named \"{1}\".".format(dll_name, name))

    def new_function(*args):
        _func = getattr(dll, name)
        _args = [common.Dll.basic_type_wrap(a) for a in args]
        args = tuple(_args)
        res = _func(*args)
        return common.Dll.basic_type_unwrap(res)

    if func.__defaults__ is not None:
        # if keyword arguments are found in the decorated function:
        raise SystemError("Dll functions don't have keyword arguments.")

    if not Dll.HasFunc_NoBody(func):
        # if decorated function declared a body:
        raise SystemError("A dll hint function can't declare a body.")

    new_function.__doc__ = func.__doc__

    return new_function

    Function decorator that implements dll functions
    with custom type hints and documentation.

    This method is similar to the C# method System.Runtime.InteropServices.DllImport().

    Decorated functions must have not declared any body
    and have the name of the wanted dll's function.

    e.g:

    class Msvcrt:
        @staticmethod
        @DllImport("C:/windows/system32/msvcrt.dll")
        def printf(text: bytes, mode: system.optional[int]): ...

    Msvcrt.printf(b'a')

    >>a

    Decorated functions can't take keyword arguments, since
    dll functions never do. To represent optional arguments,
    use system.optional as showed above.

    This syntax is only a user-made type hint for dll functions.

    If you don't need it, please use the 'Dll' class directly.
    
Function decorator that implements dll functions
with custom type hints and documentation.

This method is similar to the C# method System.Runtime.InteropServices.DllImport().

Decorated functions must have not declared any body
and have the name of the wanted dll's function.







>>a

Decorated functions can't take keyword arguments, since
dll functions never do. To represent optional arguments,
use system.optional as showed above.

This syntax is only a user-made type hint for dll functions.

If you don't need it, please use the 'Dll' class directly.
Function decorator that implements dll functions with custom type hints and documentation . This method is similar to the C# method System . Runtime . InteropServices . DllImport () . Decorated functions must have not declared any body and have the name of the wanted dll ' s function . >> a Decorated functions can ' t take keyword arguments since dll functions never do . To represent optional arguments use system . optional as showed above . This syntax is only a user - made type hint for dll functions . If you don ' t need it please use the ' Dll ' class directly .
def DllImport(func: Union[FunctionType, MethodType], file: Union[str, PathLike], type_: type[Dll.AnyDll] = Dll.WinDll):
    dll = Dll(file, type_)
    name = func.__name__
    dll_name = file.split('/')[-1]
    if not hasattr(dll, name):
        raise AttributeError("Dll \"{0}\" has no function named \"{1}\".".format(dll_name, name))
    def new_function(*args):
        _func = getattr(dll, name)
        _args = [common.Dll.basic_type_wrap(a) for a in args]
        args = tuple(_args)
        res = _func(*args)
        return common.Dll.basic_type_unwrap(res)
    if func.__defaults__ is not None:
        raise SystemError("Dll functions don't have keyword arguments.")
    if not Dll.HasFunc_NoBody(func):
        raise SystemError("A dll hint function can't declare a body.")
    new_function.__doc__ = func.__doc__
    return new_function
def DllImport ( func : Union [ FunctionType , MethodType ] , file : Union [ str , PathLike ] , type_ : type [ Dll . AnyDll ] = Dll . WinDll ) : dll = Dll ( file , type_ ) name = func . __name__ dll_name = file . split ( '/' ) [ - 1 ] if not hasattr ( dll , name ) : raise AttributeError ( "Dll \"{0}\" has no function named \"{1}\"." . format ( dll_name , name ) ) def new_function ( * args ) : _func = getattr ( dll , name ) _args = [ common . Dll . basic_type_wrap ( a ) for a in args ] args = tuple ( _args ) res = _func ( * args ) return common . Dll . basic_type_unwrap ( res ) if func . __defaults__ is not None : raise SystemError ( "Dll functions don't have keyword arguments." ) if not Dll . HasFunc_NoBody ( func ) : raise SystemError ( "A dll hint function can't declare a body." ) new_function . __doc__ = func . __doc__ return new_function
Function decorator that implements dll functions
with custom type hints and documentation.
Function decorator that implements dll functions with custom type hints and documentation .
"""
    Function decorator that implements dll functions
    with custom type hints and documentation.

    This method is similar to the C# method System.Runtime.InteropServices.DllImport().

    Decorated functions must have not declared any body
    and have the name of the wanted dll's function.

    e.g:

    class Msvcrt:
        @staticmethod
        @DllImport("C:/windows/system32/msvcrt.dll")
        def printf(text: bytes, mode: system.optional[int]): ...

    Msvcrt.printf(b'a')

    >>a

    Decorated functions can't take keyword arguments, since
    dll functions never do. To represent optional arguments,
    use system.optional as showed above.

    This syntax is only a user-made type hint for dll functions.

    If you don't need it, please use the 'Dll' class directly.
    """ # if the function is not found in dll: # if keyword arguments are found in the decorated function: # if decorated function declared a body:
func
Union[FunctionType, MethodType]
file
Union[str, PathLike]
type_
type[Dll.AnyDll]