def generic_cast(name):
    """
    Generates a function to cast pointers.

    :param name: the pointer name
    :return: string
    """

    text = (
        'def {name}Pointer(obj):\n'
        '    """\n'
        '    Casts an object to {name} pointer type.\n'
        '\n'
        '    :param obj: a generic object\n'
        '    :return: {name}\n'
        '    """\n'
        '\n'
        '    return ctypes.cast(obj, ctypes.POINTER({name}))\n\n\n'
    )

    return text.format(name=name)