from ctypes import c_int, c_void_p, c_ushort, Structure, POINTER, CFUNCTYPE
from .dtypes import DumpiTime, DumpiPerfInfo


CALLBACK = CFUNCTYPE(c_int, c_void_p, c_ushort, POINTER(DumpiTime), 
    POINTER(DumpiTime), POINTER(DumpiPerfInfo), c_void_p)

class DumpiCallbacks(Structure):
    _fields_ = [
        ("on_send", CALLBACK),
        ("on_recv", CALLBACK),
        ("on_get_count", CALLBACK),
        ("on_bsend", CALLBACK),
        ("on_ssend", CALLBACK),
        ("on_rsend", CALLBACK),
        ("on_buffer_attach", CALLBACK),
        ("on_buffer_detach", CALLBACK),
        ("on_isend", CALLBACK),
        ("on_ibsend", CALLBACK),
        ("on_issend", CALLBACK),
        ("on_irsend", CALLBACK),
        ("on_irecv", CALLBACK),
        ("on_wait", CALLBACK),
        ("on_test", CALLBACK),
        ("on_request_free", CALLBACK),
        ("on_waitany", CALLBACK),
        ("on_testany", CALLBACK),
        ("on_waitall", CALLBACK),
        ("on_testall", CALLBACK),
        ("on_waitsome", CALLBACK),
        ("on_testsome", CALLBACK),
        ("on_iprobe", CALLBACK),
        ("on_probe", CALLBACK),
        ("on_cancel", CALLBACK),
        ("on_test_cancelled", CALLBACK),
        ("on_send_init", CALLBACK),
        ("on_bsend_init", CALLBACK),
        ("on_ssend_init", CALLBACK),
        ("on_rsend_init", CALLBACK),
        ("on_recv_init", CALLBACK),
        ("on_start", CALLBACK),
        ("on_startall", CALLBACK),
        ("on_sendrecv", CALLBACK),
        ("on_sendrecv_replace", CALLBACK),
        ("on_type_contiguous", CALLBACK),
        ("on_type_vector", CALLBACK),
        ("on_type_hvector", CALLBACK),
        ("on_type_indexed", CALLBACK),
        ("on_type_hindexed", CALLBACK),
        ("on_type_struct", CALLBACK),
        ("on_address", CALLBACK),
        ("on_type_extent", CALLBACK),
        ("on_type_size", CALLBACK),
        ("on_type_lb", CALLBACK),
        ("on_type_ub", CALLBACK),
        ("on_type_commit", CALLBACK),
        ("on_type_free", CALLBACK),
        ("on_get_elements", CALLBACK),
        ("on_pack", CALLBACK),
        ("on_unpack", CALLBACK),
        ("on_pack_size", CALLBACK),
        ("on_barrier", CALLBACK),
        ("on_bcast", CALLBACK),
        ("on_gather", CALLBACK),
        ("on_gatherv", CALLBACK),
        ("on_scatter", CALLBACK),
        ("on_scatterv", CALLBACK),
        ("on_allgather", CALLBACK),
        ("on_allgatherv", CALLBACK),
        ("on_alltoall", CALLBACK),
        ("on_alltoallv", CALLBACK),
        ("on_reduce", CALLBACK),
        ("on_op_create", CALLBACK),
        ("on_op_free", CALLBACK),
        ("on_allreduce", CALLBACK),
        ("on_reduce_scatter", CALLBACK),
        ("on_scan", CALLBACK),
        ("on_group_size", CALLBACK),
        ("on_group_rank", CALLBACK),
        ("on_group_translate_ranks", CALLBACK),
        ("on_group_compare", CALLBACK),
        ("on_comm_group", CALLBACK),
        ("on_group_union", CALLBACK),
        ("on_group_intersection", CALLBACK),
        ("on_group_difference", CALLBACK),
        ("on_group_incl", CALLBACK),
        ("on_group_excl", CALLBACK),
        ("on_group_range_incl", CALLBACK),
        ("on_group_range_excl", CALLBACK),
        ("on_group_free", CALLBACK),
        ("on_comm_size", CALLBACK),
        ("on_comm_rank", CALLBACK),
        ("on_comm_compare", CALLBACK),
        ("on_comm_dup", CALLBACK),
        ("on_comm_create", CALLBACK),
        ("on_comm_split", CALLBACK),
        ("on_comm_free", CALLBACK),
        ("on_comm_test_inter", CALLBACK),
        ("on_comm_remote_size", CALLBACK),
        ("on_comm_remote_group", CALLBACK),
        ("on_intercomm_create", CALLBACK),
        ("on_intercomm_merge", CALLBACK),
        ("on_keyval_create", CALLBACK),
        ("on_keyval_free", CALLBACK),
        ("on_attr_put", CALLBACK),
        ("on_attr_get", CALLBACK),
        ("on_attr_delete", CALLBACK),
        ("on_topo_test", CALLBACK),
        ("on_cart_create", CALLBACK),
        ("on_dims_create", CALLBACK),
        ("on_graph_create", CALLBACK),
        ("on_graphdims_get", CALLBACK),
        ("on_graph_get", CALLBACK),
        ("on_cartdim_get", CALLBACK),
        ("on_cart_get", CALLBACK),
        ("on_cart_rank", CALLBACK),
        ("on_cart_coords", CALLBACK),
        ("on_graph_neighbors_count", CALLBACK),
        ("on_graph_neighbors", CALLBACK),
        ("on_cart_shift", CALLBACK),
        ("on_cart_sub", CALLBACK),
        ("on_cart_map", CALLBACK),
        ("on_graph_map", CALLBACK),
        ("on_get_processor_name", CALLBACK),
        ("on_get_version", CALLBACK),
        ("on_errhandler_create", CALLBACK),
        ("on_errhandler_set", CALLBACK),
        ("on_errhandler_get", CALLBACK),
        ("on_errhandler_free", CALLBACK),
        ("on_error_string", CALLBACK),
        ("on_error_class", CALLBACK),
        ("on_wtime", CALLBACK),
        ("on_wtick", CALLBACK),
        ("on_init", CALLBACK),
        ("on_finalize", CALLBACK),
        ("on_initialized", CALLBACK),
        ("on_abort", CALLBACK),
        ("on_close_port", CALLBACK),
        ("on_comm_accept", CALLBACK),
        ("on_comm_connect", CALLBACK),
        ("on_comm_disconnect", CALLBACK),
        ("on_comm_get_parent", CALLBACK),
        ("on_comm_join", CALLBACK),
        ("on_comm_spawn", CALLBACK),
        ("on_comm_spawn_multiple", CALLBACK),
        ("on_lookup_name", CALLBACK),
        ("on_open_port", CALLBACK),
        ("on_publish_name", CALLBACK),
        ("on_unpublish_name", CALLBACK),
        ("on_accumulate", CALLBACK),
        ("on_get", CALLBACK),
        ("on_put", CALLBACK),
        ("on_win_complete", CALLBACK),
        ("on_win_create", CALLBACK),
        ("on_win_fence", CALLBACK),
        ("on_win_free", CALLBACK),
        ("on_win_get_group", CALLBACK),
        ("on_win_lock", CALLBACK),
        ("on_win_post", CALLBACK),
        ("on_win_start", CALLBACK),
        ("on_win_test", CALLBACK),
        ("on_win_unlock", CALLBACK),
        ("on_win_wait", CALLBACK),
        ("on_alltoallw", CALLBACK),
        ("on_exscan", CALLBACK),
        ("on_add_error_class", CALLBACK),
        ("on_add_error_code", CALLBACK),
        ("on_add_error_string", CALLBACK),
        ("on_comm_call_errhandler", CALLBACK),
        ("on_comm_create_keyval", CALLBACK),
        ("on_comm_delete_attr", CALLBACK),
        ("on_comm_free_keyval", CALLBACK),
        ("on_comm_get_attr", CALLBACK),
        ("on_comm_get_name", CALLBACK),
        ("on_comm_set_attr", CALLBACK),
        ("on_comm_set_name", CALLBACK),
        ("on_file_call_errhandler", CALLBACK),
        ("on_grequest_complete", CALLBACK),
        ("on_grequest_start", CALLBACK),
        ("on_init_thread", CALLBACK),
        ("on_is_thread_main", CALLBACK),
        ("on_query_thread", CALLBACK),
        ("on_status_set_cancelled", CALLBACK),
        ("on_status_set_elements", CALLBACK),
        ("on_type_create_keyval", CALLBACK),
        ("on_type_delete_attr", CALLBACK),
        ("on_type_dup", CALLBACK),
        ("on_type_free_keyval", CALLBACK),
        ("on_type_get_attr", CALLBACK),
        ("on_type_get_contents", CALLBACK),
        ("on_type_get_envelope", CALLBACK),
        ("on_type_get_name", CALLBACK),
        ("on_type_set_attr", CALLBACK),
        ("on_type_set_name", CALLBACK),
        ("on_type_match_size", CALLBACK),
        ("on_win_call_errhandler", CALLBACK),
        ("on_win_create_keyval", CALLBACK),
        ("on_win_delete_attr", CALLBACK),
        ("on_win_free_keyval", CALLBACK),
        ("on_win_get_attr", CALLBACK),
        ("on_win_get_name", CALLBACK),
        ("on_win_set_attr", CALLBACK),
        ("on_win_set_name", CALLBACK),
        ("on_alloc_mem", CALLBACK),
        ("on_comm_create_errhandler", CALLBACK),
        ("on_comm_get_errhandler", CALLBACK),
        ("on_comm_set_errhandler", CALLBACK),
        ("on_file_create_errhandler", CALLBACK),
        ("on_file_get_errhandler", CALLBACK),
        ("on_file_set_errhandler", CALLBACK),
        ("on_finalized", CALLBACK),
        ("on_free_mem", CALLBACK),
        ("on_get_address", CALLBACK),
        ("on_info_create", CALLBACK),
        ("on_info_delete", CALLBACK),
        ("on_info_dup", CALLBACK),
        ("on_info_free", CALLBACK),
        ("on_info_get", CALLBACK),
        ("on_info_get_nkeys", CALLBACK),
        ("on_info_get_nthkey", CALLBACK),
        ("on_info_get_valuelen", CALLBACK),
        ("on_info_set", CALLBACK),
        ("on_pack_external", CALLBACK),
        ("on_pack_external_size", CALLBACK),
        ("on_request_get_status", CALLBACK),
        ("on_type_create_darray", CALLBACK),
        ("on_type_create_hindexed", CALLBACK),
        ("on_type_create_hvector", CALLBACK),
        ("on_type_create_indexed_block", CALLBACK),
        ("on_type_create_resized", CALLBACK),
        ("on_type_create_struct", CALLBACK),
        ("on_type_create_subarray", CALLBACK),
        ("on_type_get_extent", CALLBACK),
        ("on_type_get_true_extent", CALLBACK),
        ("on_unpack_external", CALLBACK),
        ("on_win_create_errhandler", CALLBACK),
        ("on_win_get_errhandler", CALLBACK),
        ("on_win_set_errhandler", CALLBACK),
        ("on_file_open", CALLBACK),
        ("on_file_close", CALLBACK),
        ("on_file_delete", CALLBACK),
        ("on_file_set_size", CALLBACK),
        ("on_file_preallocate", CALLBACK),
        ("on_file_get_size", CALLBACK),
        ("on_file_get_group", CALLBACK),
        ("on_file_get_amode", CALLBACK),
        ("on_file_set_info", CALLBACK),
        ("on_file_get_info", CALLBACK),
        ("on_file_set_view", CALLBACK),
        ("on_file_get_view", CALLBACK),
        ("on_file_read_at", CALLBACK),
        ("on_file_read_at_all", CALLBACK),
        ("on_file_write_at", CALLBACK),
        ("on_file_write_at_all", CALLBACK),
        ("on_file_iread_at", CALLBACK),
        ("on_file_iwrite_at", CALLBACK),
        ("on_file_read", CALLBACK),
        ("on_file_read_all", CALLBACK),
        ("on_file_write", CALLBACK),
        ("on_file_write_all", CALLBACK),
        ("on_file_iread", CALLBACK),
        ("on_file_iwrite", CALLBACK),
        ("on_file_seek", CALLBACK),
        ("on_file_get_position", CALLBACK),
        ("on_file_get_byte_offset", CALLBACK),
        ("on_file_read_shared", CALLBACK),
        ("on_file_write_shared", CALLBACK),
        ("on_file_iread_shared", CALLBACK),
        ("on_file_iwrite_shared", CALLBACK),
        ("on_file_read_ordered", CALLBACK),
        ("on_file_write_ordered", CALLBACK),
        ("on_file_seek_shared", CALLBACK),
        ("on_file_get_position_shared", CALLBACK),
        ("on_file_read_at_all_begin", CALLBACK),
        ("on_file_read_at_all_end", CALLBACK),
        ("on_file_write_at_all_begin", CALLBACK),
        ("on_file_write_at_all_end", CALLBACK),
        ("on_file_read_all_begin", CALLBACK),
        ("on_file_read_all_end", CALLBACK),
        ("on_file_write_all_begin", CALLBACK),
        ("on_file_write_all_end", CALLBACK),
        ("on_file_read_ordered_begin", CALLBACK),
        ("on_file_read_ordered_end", CALLBACK),
        ("on_file_write_ordered_begin", CALLBACK),
        ("on_file_write_ordered_end", CALLBACK),
        ("on_file_get_type_extent", CALLBACK),
        ("on_register_datarep", CALLBACK),
        ("on_file_set_atomicity", CALLBACK),
        ("on_file_get_atomicity", CALLBACK),
        ("on_file_sync", CALLBACK),
        ("on_iotest", CALLBACK),
        ("on_iowait", CALLBACK),
        ("on_iotestall", CALLBACK),
        ("on_iowaitall", CALLBACK),
        ("on_iotestany", CALLBACK),
        ("on_iowaitany", CALLBACK),
        ("on_iowaitsome", CALLBACK),
        ("on_iotestsome", CALLBACK),
        ("on_function_enter", CALLBACK),
        ("on_function_exit", CALLBACK)
    ]
