# Path: resources/lib/PhoneBooks/pyicloud/vendorlibs/win32ctypes/pywintypes.py
# class error(Exception):
#     def __init__(self, *args, **kw):
#         nargs = len(args)
#         if nargs > 0:
#             self.winerror = args[0]
#         else:
#             self.winerror = None
#         if nargs > 1:
#             self.funcname = args[1]
#         else:
#             self.funcname = None
#         if nargs > 2:
#             self.strerror = args[2]
#         else:
#             self.strerror = None
#         Exception.__init__(self, *args, **kw)


from ctypes import GetLastError, FormatError
from .pywintypes import error
# This file is open source software distributed according to the terms in
# LICENSE.txt
#

""" Utility functions to help with python wrapping.
"""
from __future__ import absolute_import




def function_factory(
        function,  argument_types=None, return_type=None,
        error_checking=None):
    if argument_types is not None:
        function.argtypes = argument_types
    function.restype = return_type
    if error_checking is not None:
        function.errcheck = error_checking
    return function


def check_null_factory(func_name=None):
    def check_null(result, func, arguments, *args):
        if result is None:
            code = GetLastError()
            description = FormatError(code).strip()
            if func_name is None:
                raise error(code, func.__name__, description)
            else:

# Path: resources/lib/PhoneBooks/pyicloud/vendorlibs/win32ctypes/pywintypes.py
# class error(Exception):
#     def __init__(self, *args, **kw):
#         nargs = len(args)
#         if nargs > 0:
#             self.winerror = args[0]
#         else:
#             self.winerror = None
#         if nargs > 1:
#             self.funcname = args[1]
#         else:
#             self.funcname = None
#         if nargs > 2:
#             self.strerror = args[2]
#         else:
#             self.strerror = None
#         Exception.__init__(self, *args, **kw)


# Path: resources/lib/PhoneBooks/pyicloud/vendorlibs/win32ctypes/_util.py
from ctypes import GetLastError, FormatError
from .pywintypes import error

# This file is open source software distributed according to the terms in
# LICENSE.txt
#

""" Utility functions to help with python wrapping.
"""
from __future__ import absolute_import




def function_factory(
        function,  argument_types=None, return_type=None,
        error_checking=None):
    if argument_types is not None:
        function.argtypes = argument_types
    function.restype = return_type
    if error_checking is not None:
        function.errcheck = error_checking
    return function


def check_null_factory(func_name=None):
    def check_null(result, func, arguments, *args):
        if result is None:
            code = GetLastError()
            description = FormatError(code).strip()
            if func_name is None:
                raise error(code, func.__name__, description)
            else:

                raise error(code, func_name, description)