Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 1 | #region Copyright notice and license |
| 2 | |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | // Copyright 2015 gRPC authors. |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 4 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 5 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | // you may not use this file except in compliance with the License. |
| 7 | // You may obtain a copy of the License at |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 8 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | // http://www.apache.org/licenses/LICENSE-2.0 |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 10 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 11 | // Unless required by applicable law or agreed to in writing, software |
| 12 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | // See the License for the specific language governing permissions and |
| 15 | // limitations under the License. |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 16 | |
| 17 | #endregion |
| 18 | |
| 19 | using System; |
| 20 | using System.Collections.Concurrent; |
| 21 | using System.Diagnostics; |
| 22 | using System.IO; |
| 23 | using System.Reflection; |
| 24 | using System.Runtime.InteropServices; |
| 25 | using System.Threading; |
| 26 | |
| 27 | using Grpc.Core.Logging; |
| 28 | using Grpc.Core.Utils; |
| 29 | |
| 30 | namespace Grpc.Core.Internal |
| 31 | { |
| 32 | /// <summary> |
| 33 | /// Provides access to all native methods provided by <c>NativeExtension</c>. |
| 34 | /// An extra level of indirection is added to P/Invoke calls to allow intelligent loading |
| 35 | /// of the right configuration of the native extension based on current platform, architecture etc. |
| 36 | /// </summary> |
| 37 | internal class NativeMethods |
| 38 | { |
| 39 | #region Native methods |
| 40 | |
| 41 | public readonly Delegates.grpcsharp_init_delegate grpcsharp_init; |
| 42 | public readonly Delegates.grpcsharp_shutdown_delegate grpcsharp_shutdown; |
| 43 | public readonly Delegates.grpcsharp_version_string_delegate grpcsharp_version_string; |
| 44 | |
| 45 | public readonly Delegates.grpcsharp_batch_context_create_delegate grpcsharp_batch_context_create; |
| 46 | public readonly Delegates.grpcsharp_batch_context_recv_initial_metadata_delegate grpcsharp_batch_context_recv_initial_metadata; |
| 47 | public readonly Delegates.grpcsharp_batch_context_recv_message_length_delegate grpcsharp_batch_context_recv_message_length; |
| 48 | public readonly Delegates.grpcsharp_batch_context_recv_message_to_buffer_delegate grpcsharp_batch_context_recv_message_to_buffer; |
| 49 | public readonly Delegates.grpcsharp_batch_context_recv_status_on_client_status_delegate grpcsharp_batch_context_recv_status_on_client_status; |
| 50 | public readonly Delegates.grpcsharp_batch_context_recv_status_on_client_details_delegate grpcsharp_batch_context_recv_status_on_client_details; |
| 51 | public readonly Delegates.grpcsharp_batch_context_recv_status_on_client_trailing_metadata_delegate grpcsharp_batch_context_recv_status_on_client_trailing_metadata; |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 52 | public readonly Delegates.grpcsharp_batch_context_recv_close_on_server_cancelled_delegate grpcsharp_batch_context_recv_close_on_server_cancelled; |
| 53 | public readonly Delegates.grpcsharp_batch_context_destroy_delegate grpcsharp_batch_context_destroy; |
| 54 | |
Jan Tattermusch | 6e90171 | 2016-10-21 00:42:37 +0200 | [diff] [blame] | 55 | public readonly Delegates.grpcsharp_request_call_context_create_delegate grpcsharp_request_call_context_create; |
| 56 | public readonly Delegates.grpcsharp_request_call_context_call_delegate grpcsharp_request_call_context_call; |
| 57 | public readonly Delegates.grpcsharp_request_call_context_method_delegate grpcsharp_request_call_context_method; |
| 58 | public readonly Delegates.grpcsharp_request_call_context_host_delegate grpcsharp_request_call_context_host; |
| 59 | public readonly Delegates.grpcsharp_request_call_context_deadline_delegate grpcsharp_request_call_context_deadline; |
| 60 | public readonly Delegates.grpcsharp_request_call_context_request_metadata_delegate grpcsharp_request_call_context_request_metadata; |
| 61 | public readonly Delegates.grpcsharp_request_call_context_destroy_delegate grpcsharp_request_call_context_destroy; |
| 62 | |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 63 | public readonly Delegates.grpcsharp_composite_call_credentials_create_delegate grpcsharp_composite_call_credentials_create; |
| 64 | public readonly Delegates.grpcsharp_call_credentials_release_delegate grpcsharp_call_credentials_release; |
| 65 | |
| 66 | public readonly Delegates.grpcsharp_call_cancel_delegate grpcsharp_call_cancel; |
| 67 | public readonly Delegates.grpcsharp_call_cancel_with_status_delegate grpcsharp_call_cancel_with_status; |
| 68 | public readonly Delegates.grpcsharp_call_start_unary_delegate grpcsharp_call_start_unary; |
| 69 | public readonly Delegates.grpcsharp_call_start_client_streaming_delegate grpcsharp_call_start_client_streaming; |
| 70 | public readonly Delegates.grpcsharp_call_start_server_streaming_delegate grpcsharp_call_start_server_streaming; |
| 71 | public readonly Delegates.grpcsharp_call_start_duplex_streaming_delegate grpcsharp_call_start_duplex_streaming; |
| 72 | public readonly Delegates.grpcsharp_call_send_message_delegate grpcsharp_call_send_message; |
| 73 | public readonly Delegates.grpcsharp_call_send_close_from_client_delegate grpcsharp_call_send_close_from_client; |
| 74 | public readonly Delegates.grpcsharp_call_send_status_from_server_delegate grpcsharp_call_send_status_from_server; |
| 75 | public readonly Delegates.grpcsharp_call_recv_message_delegate grpcsharp_call_recv_message; |
| 76 | public readonly Delegates.grpcsharp_call_recv_initial_metadata_delegate grpcsharp_call_recv_initial_metadata; |
| 77 | public readonly Delegates.grpcsharp_call_start_serverside_delegate grpcsharp_call_start_serverside; |
| 78 | public readonly Delegates.grpcsharp_call_send_initial_metadata_delegate grpcsharp_call_send_initial_metadata; |
| 79 | public readonly Delegates.grpcsharp_call_set_credentials_delegate grpcsharp_call_set_credentials; |
| 80 | public readonly Delegates.grpcsharp_call_get_peer_delegate grpcsharp_call_get_peer; |
| 81 | public readonly Delegates.grpcsharp_call_destroy_delegate grpcsharp_call_destroy; |
| 82 | |
| 83 | public readonly Delegates.grpcsharp_channel_args_create_delegate grpcsharp_channel_args_create; |
| 84 | public readonly Delegates.grpcsharp_channel_args_set_string_delegate grpcsharp_channel_args_set_string; |
| 85 | public readonly Delegates.grpcsharp_channel_args_set_integer_delegate grpcsharp_channel_args_set_integer; |
| 86 | public readonly Delegates.grpcsharp_channel_args_destroy_delegate grpcsharp_channel_args_destroy; |
| 87 | |
Jan Tattermusch | 660c15b | 2016-02-02 06:39:10 -0800 | [diff] [blame] | 88 | public readonly Delegates.grpcsharp_override_default_ssl_roots grpcsharp_override_default_ssl_roots; |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 89 | public readonly Delegates.grpcsharp_ssl_credentials_create_delegate grpcsharp_ssl_credentials_create; |
| 90 | public readonly Delegates.grpcsharp_composite_channel_credentials_create_delegate grpcsharp_composite_channel_credentials_create; |
| 91 | public readonly Delegates.grpcsharp_channel_credentials_release_delegate grpcsharp_channel_credentials_release; |
| 92 | |
| 93 | public readonly Delegates.grpcsharp_insecure_channel_create_delegate grpcsharp_insecure_channel_create; |
| 94 | public readonly Delegates.grpcsharp_secure_channel_create_delegate grpcsharp_secure_channel_create; |
| 95 | public readonly Delegates.grpcsharp_channel_create_call_delegate grpcsharp_channel_create_call; |
| 96 | public readonly Delegates.grpcsharp_channel_check_connectivity_state_delegate grpcsharp_channel_check_connectivity_state; |
| 97 | public readonly Delegates.grpcsharp_channel_watch_connectivity_state_delegate grpcsharp_channel_watch_connectivity_state; |
| 98 | public readonly Delegates.grpcsharp_channel_get_target_delegate grpcsharp_channel_get_target; |
| 99 | public readonly Delegates.grpcsharp_channel_destroy_delegate grpcsharp_channel_destroy; |
| 100 | |
| 101 | public readonly Delegates.grpcsharp_sizeof_grpc_event_delegate grpcsharp_sizeof_grpc_event; |
| 102 | |
Jan Tattermusch | b746294 | 2017-03-08 19:30:21 +0100 | [diff] [blame] | 103 | public readonly Delegates.grpcsharp_completion_queue_create_async_delegate grpcsharp_completion_queue_create_async; |
| 104 | public readonly Delegates.grpcsharp_completion_queue_create_sync_delegate grpcsharp_completion_queue_create_sync; |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 105 | public readonly Delegates.grpcsharp_completion_queue_shutdown_delegate grpcsharp_completion_queue_shutdown; |
| 106 | public readonly Delegates.grpcsharp_completion_queue_next_delegate grpcsharp_completion_queue_next; |
| 107 | public readonly Delegates.grpcsharp_completion_queue_pluck_delegate grpcsharp_completion_queue_pluck; |
| 108 | public readonly Delegates.grpcsharp_completion_queue_destroy_delegate grpcsharp_completion_queue_destroy; |
| 109 | |
| 110 | public readonly Delegates.gprsharp_free_delegate gprsharp_free; |
| 111 | |
| 112 | public readonly Delegates.grpcsharp_metadata_array_create_delegate grpcsharp_metadata_array_create; |
| 113 | public readonly Delegates.grpcsharp_metadata_array_add_delegate grpcsharp_metadata_array_add; |
| 114 | public readonly Delegates.grpcsharp_metadata_array_count_delegate grpcsharp_metadata_array_count; |
| 115 | public readonly Delegates.grpcsharp_metadata_array_get_key_delegate grpcsharp_metadata_array_get_key; |
| 116 | public readonly Delegates.grpcsharp_metadata_array_get_value_delegate grpcsharp_metadata_array_get_value; |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 117 | public readonly Delegates.grpcsharp_metadata_array_destroy_full_delegate grpcsharp_metadata_array_destroy_full; |
| 118 | |
| 119 | public readonly Delegates.grpcsharp_redirect_log_delegate grpcsharp_redirect_log; |
| 120 | |
| 121 | public readonly Delegates.grpcsharp_metadata_credentials_create_from_plugin_delegate grpcsharp_metadata_credentials_create_from_plugin; |
| 122 | public readonly Delegates.grpcsharp_metadata_credentials_notify_from_plugin_delegate grpcsharp_metadata_credentials_notify_from_plugin; |
| 123 | |
| 124 | public readonly Delegates.grpcsharp_ssl_server_credentials_create_delegate grpcsharp_ssl_server_credentials_create; |
| 125 | public readonly Delegates.grpcsharp_server_credentials_release_delegate grpcsharp_server_credentials_release; |
| 126 | |
| 127 | public readonly Delegates.grpcsharp_server_create_delegate grpcsharp_server_create; |
Jan Tattermusch | 5ee8e77 | 2016-05-24 16:17:10 -0400 | [diff] [blame] | 128 | public readonly Delegates.grpcsharp_server_register_completion_queue_delegate grpcsharp_server_register_completion_queue; |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 129 | public readonly Delegates.grpcsharp_server_add_insecure_http2_port_delegate grpcsharp_server_add_insecure_http2_port; |
| 130 | public readonly Delegates.grpcsharp_server_add_secure_http2_port_delegate grpcsharp_server_add_secure_http2_port; |
| 131 | public readonly Delegates.grpcsharp_server_start_delegate grpcsharp_server_start; |
| 132 | public readonly Delegates.grpcsharp_server_request_call_delegate grpcsharp_server_request_call; |
| 133 | public readonly Delegates.grpcsharp_server_cancel_all_calls_delegate grpcsharp_server_cancel_all_calls; |
| 134 | public readonly Delegates.grpcsharp_server_shutdown_and_notify_callback_delegate grpcsharp_server_shutdown_and_notify_callback; |
| 135 | public readonly Delegates.grpcsharp_server_destroy_delegate grpcsharp_server_destroy; |
| 136 | |
Jan Tattermusch | c9b03fe | 2017-02-06 08:45:00 -0800 | [diff] [blame] | 137 | public readonly Delegates.grpcsharp_call_auth_context_delegate grpcsharp_call_auth_context; |
| 138 | public readonly Delegates.grpcsharp_auth_context_peer_identity_property_name_delegate grpcsharp_auth_context_peer_identity_property_name; |
| 139 | public readonly Delegates.grpcsharp_auth_context_property_iterator_delegate grpcsharp_auth_context_property_iterator; |
| 140 | public readonly Delegates.grpcsharp_auth_property_iterator_next_delegate grpcsharp_auth_property_iterator_next; |
| 141 | public readonly Delegates.grpcsharp_auth_context_release_delegate grpcsharp_auth_context_release; |
| 142 | |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 143 | public readonly Delegates.gprsharp_now_delegate gprsharp_now; |
| 144 | public readonly Delegates.gprsharp_inf_future_delegate gprsharp_inf_future; |
| 145 | public readonly Delegates.gprsharp_inf_past_delegate gprsharp_inf_past; |
| 146 | public readonly Delegates.gprsharp_convert_clock_type_delegate gprsharp_convert_clock_type; |
| 147 | public readonly Delegates.gprsharp_sizeof_timespec_delegate gprsharp_sizeof_timespec; |
| 148 | |
| 149 | public readonly Delegates.grpcsharp_test_callback_delegate grpcsharp_test_callback; |
| 150 | public readonly Delegates.grpcsharp_test_nop_delegate grpcsharp_test_nop; |
| 151 | |
Jan Tattermusch | 645ae74 | 2017-05-22 08:46:26 -0700 | [diff] [blame] | 152 | public readonly Delegates.grpcsharp_test_override_method_delegate grpcsharp_test_override_method; |
| 153 | |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 154 | #endregion |
| 155 | |
| 156 | public NativeMethods(UnmanagedLibrary library) |
| 157 | { |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 158 | this.grpcsharp_init = GetMethodDelegate<Delegates.grpcsharp_init_delegate>(library); |
| 159 | this.grpcsharp_shutdown = GetMethodDelegate<Delegates.grpcsharp_shutdown_delegate>(library); |
| 160 | this.grpcsharp_version_string = GetMethodDelegate<Delegates.grpcsharp_version_string_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 161 | |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 162 | this.grpcsharp_batch_context_create = GetMethodDelegate<Delegates.grpcsharp_batch_context_create_delegate>(library); |
| 163 | this.grpcsharp_batch_context_recv_initial_metadata = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_initial_metadata_delegate>(library); |
| 164 | this.grpcsharp_batch_context_recv_message_length = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_message_length_delegate>(library); |
| 165 | this.grpcsharp_batch_context_recv_message_to_buffer = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_message_to_buffer_delegate>(library); |
| 166 | this.grpcsharp_batch_context_recv_status_on_client_status = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_status_on_client_status_delegate>(library); |
| 167 | this.grpcsharp_batch_context_recv_status_on_client_details = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_status_on_client_details_delegate>(library); |
| 168 | this.grpcsharp_batch_context_recv_status_on_client_trailing_metadata = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_status_on_client_trailing_metadata_delegate>(library); |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 169 | this.grpcsharp_batch_context_recv_close_on_server_cancelled = GetMethodDelegate<Delegates.grpcsharp_batch_context_recv_close_on_server_cancelled_delegate>(library); |
| 170 | this.grpcsharp_batch_context_destroy = GetMethodDelegate<Delegates.grpcsharp_batch_context_destroy_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 171 | |
Jan Tattermusch | 6e90171 | 2016-10-21 00:42:37 +0200 | [diff] [blame] | 172 | this.grpcsharp_request_call_context_create = GetMethodDelegate<Delegates.grpcsharp_request_call_context_create_delegate>(library); |
| 173 | this.grpcsharp_request_call_context_call = GetMethodDelegate<Delegates.grpcsharp_request_call_context_call_delegate>(library); |
| 174 | this.grpcsharp_request_call_context_method = GetMethodDelegate<Delegates.grpcsharp_request_call_context_method_delegate>(library); |
| 175 | this.grpcsharp_request_call_context_host = GetMethodDelegate<Delegates.grpcsharp_request_call_context_host_delegate>(library); |
| 176 | this.grpcsharp_request_call_context_deadline = GetMethodDelegate<Delegates.grpcsharp_request_call_context_deadline_delegate>(library); |
| 177 | this.grpcsharp_request_call_context_request_metadata = GetMethodDelegate<Delegates.grpcsharp_request_call_context_request_metadata_delegate>(library); |
| 178 | this.grpcsharp_request_call_context_destroy = GetMethodDelegate<Delegates.grpcsharp_request_call_context_destroy_delegate>(library); |
| 179 | |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 180 | this.grpcsharp_composite_call_credentials_create = GetMethodDelegate<Delegates.grpcsharp_composite_call_credentials_create_delegate>(library); |
| 181 | this.grpcsharp_call_credentials_release = GetMethodDelegate<Delegates.grpcsharp_call_credentials_release_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 182 | |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 183 | this.grpcsharp_call_cancel = GetMethodDelegate<Delegates.grpcsharp_call_cancel_delegate>(library); |
| 184 | this.grpcsharp_call_cancel_with_status = GetMethodDelegate<Delegates.grpcsharp_call_cancel_with_status_delegate>(library); |
| 185 | this.grpcsharp_call_start_unary = GetMethodDelegate<Delegates.grpcsharp_call_start_unary_delegate>(library); |
| 186 | this.grpcsharp_call_start_client_streaming = GetMethodDelegate<Delegates.grpcsharp_call_start_client_streaming_delegate>(library); |
| 187 | this.grpcsharp_call_start_server_streaming = GetMethodDelegate<Delegates.grpcsharp_call_start_server_streaming_delegate>(library); |
| 188 | this.grpcsharp_call_start_duplex_streaming = GetMethodDelegate<Delegates.grpcsharp_call_start_duplex_streaming_delegate>(library); |
| 189 | this.grpcsharp_call_send_message = GetMethodDelegate<Delegates.grpcsharp_call_send_message_delegate>(library); |
| 190 | this.grpcsharp_call_send_close_from_client = GetMethodDelegate<Delegates.grpcsharp_call_send_close_from_client_delegate>(library); |
| 191 | this.grpcsharp_call_send_status_from_server = GetMethodDelegate<Delegates.grpcsharp_call_send_status_from_server_delegate>(library); |
| 192 | this.grpcsharp_call_recv_message = GetMethodDelegate<Delegates.grpcsharp_call_recv_message_delegate>(library); |
| 193 | this.grpcsharp_call_recv_initial_metadata = GetMethodDelegate<Delegates.grpcsharp_call_recv_initial_metadata_delegate>(library); |
| 194 | this.grpcsharp_call_start_serverside = GetMethodDelegate<Delegates.grpcsharp_call_start_serverside_delegate>(library); |
| 195 | this.grpcsharp_call_send_initial_metadata = GetMethodDelegate<Delegates.grpcsharp_call_send_initial_metadata_delegate>(library); |
| 196 | this.grpcsharp_call_set_credentials = GetMethodDelegate<Delegates.grpcsharp_call_set_credentials_delegate>(library); |
| 197 | this.grpcsharp_call_get_peer = GetMethodDelegate<Delegates.grpcsharp_call_get_peer_delegate>(library); |
| 198 | this.grpcsharp_call_destroy = GetMethodDelegate<Delegates.grpcsharp_call_destroy_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 199 | |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 200 | this.grpcsharp_channel_args_create = GetMethodDelegate<Delegates.grpcsharp_channel_args_create_delegate>(library); |
| 201 | this.grpcsharp_channel_args_set_string = GetMethodDelegate<Delegates.grpcsharp_channel_args_set_string_delegate>(library); |
| 202 | this.grpcsharp_channel_args_set_integer = GetMethodDelegate<Delegates.grpcsharp_channel_args_set_integer_delegate>(library); |
| 203 | this.grpcsharp_channel_args_destroy = GetMethodDelegate<Delegates.grpcsharp_channel_args_destroy_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 204 | |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 205 | this.grpcsharp_override_default_ssl_roots = GetMethodDelegate<Delegates.grpcsharp_override_default_ssl_roots>(library); |
| 206 | this.grpcsharp_ssl_credentials_create = GetMethodDelegate<Delegates.grpcsharp_ssl_credentials_create_delegate>(library); |
| 207 | this.grpcsharp_composite_channel_credentials_create = GetMethodDelegate<Delegates.grpcsharp_composite_channel_credentials_create_delegate>(library); |
| 208 | this.grpcsharp_channel_credentials_release = GetMethodDelegate<Delegates.grpcsharp_channel_credentials_release_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 209 | |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 210 | this.grpcsharp_insecure_channel_create = GetMethodDelegate<Delegates.grpcsharp_insecure_channel_create_delegate>(library); |
| 211 | this.grpcsharp_secure_channel_create = GetMethodDelegate<Delegates.grpcsharp_secure_channel_create_delegate>(library); |
| 212 | this.grpcsharp_channel_create_call = GetMethodDelegate<Delegates.grpcsharp_channel_create_call_delegate>(library); |
| 213 | this.grpcsharp_channel_check_connectivity_state = GetMethodDelegate<Delegates.grpcsharp_channel_check_connectivity_state_delegate>(library); |
| 214 | this.grpcsharp_channel_watch_connectivity_state = GetMethodDelegate<Delegates.grpcsharp_channel_watch_connectivity_state_delegate>(library); |
| 215 | this.grpcsharp_channel_get_target = GetMethodDelegate<Delegates.grpcsharp_channel_get_target_delegate>(library); |
| 216 | this.grpcsharp_channel_destroy = GetMethodDelegate<Delegates.grpcsharp_channel_destroy_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 217 | |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 218 | this.grpcsharp_sizeof_grpc_event = GetMethodDelegate<Delegates.grpcsharp_sizeof_grpc_event_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 219 | |
Jan Tattermusch | b746294 | 2017-03-08 19:30:21 +0100 | [diff] [blame] | 220 | this.grpcsharp_completion_queue_create_async = GetMethodDelegate<Delegates.grpcsharp_completion_queue_create_async_delegate>(library); |
| 221 | this.grpcsharp_completion_queue_create_sync = GetMethodDelegate<Delegates.grpcsharp_completion_queue_create_sync_delegate>(library); |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 222 | this.grpcsharp_completion_queue_shutdown = GetMethodDelegate<Delegates.grpcsharp_completion_queue_shutdown_delegate>(library); |
| 223 | this.grpcsharp_completion_queue_next = GetMethodDelegate<Delegates.grpcsharp_completion_queue_next_delegate>(library); |
| 224 | this.grpcsharp_completion_queue_pluck = GetMethodDelegate<Delegates.grpcsharp_completion_queue_pluck_delegate>(library); |
| 225 | this.grpcsharp_completion_queue_destroy = GetMethodDelegate<Delegates.grpcsharp_completion_queue_destroy_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 226 | |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 227 | this.gprsharp_free = GetMethodDelegate<Delegates.gprsharp_free_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 228 | |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 229 | this.grpcsharp_metadata_array_create = GetMethodDelegate<Delegates.grpcsharp_metadata_array_create_delegate>(library); |
| 230 | this.grpcsharp_metadata_array_add = GetMethodDelegate<Delegates.grpcsharp_metadata_array_add_delegate>(library); |
| 231 | this.grpcsharp_metadata_array_count = GetMethodDelegate<Delegates.grpcsharp_metadata_array_count_delegate>(library); |
| 232 | this.grpcsharp_metadata_array_get_key = GetMethodDelegate<Delegates.grpcsharp_metadata_array_get_key_delegate>(library); |
| 233 | this.grpcsharp_metadata_array_get_value = GetMethodDelegate<Delegates.grpcsharp_metadata_array_get_value_delegate>(library); |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 234 | this.grpcsharp_metadata_array_destroy_full = GetMethodDelegate<Delegates.grpcsharp_metadata_array_destroy_full_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 235 | |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 236 | this.grpcsharp_redirect_log = GetMethodDelegate<Delegates.grpcsharp_redirect_log_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 237 | |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 238 | this.grpcsharp_metadata_credentials_create_from_plugin = GetMethodDelegate<Delegates.grpcsharp_metadata_credentials_create_from_plugin_delegate>(library); |
| 239 | this.grpcsharp_metadata_credentials_notify_from_plugin = GetMethodDelegate<Delegates.grpcsharp_metadata_credentials_notify_from_plugin_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 240 | |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 241 | this.grpcsharp_ssl_server_credentials_create = GetMethodDelegate<Delegates.grpcsharp_ssl_server_credentials_create_delegate>(library); |
| 242 | this.grpcsharp_server_credentials_release = GetMethodDelegate<Delegates.grpcsharp_server_credentials_release_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 243 | |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 244 | this.grpcsharp_server_create = GetMethodDelegate<Delegates.grpcsharp_server_create_delegate>(library); |
| 245 | this.grpcsharp_server_register_completion_queue = GetMethodDelegate<Delegates.grpcsharp_server_register_completion_queue_delegate>(library); |
| 246 | this.grpcsharp_server_add_insecure_http2_port = GetMethodDelegate<Delegates.grpcsharp_server_add_insecure_http2_port_delegate>(library); |
| 247 | this.grpcsharp_server_add_secure_http2_port = GetMethodDelegate<Delegates.grpcsharp_server_add_secure_http2_port_delegate>(library); |
| 248 | this.grpcsharp_server_start = GetMethodDelegate<Delegates.grpcsharp_server_start_delegate>(library); |
| 249 | this.grpcsharp_server_request_call = GetMethodDelegate<Delegates.grpcsharp_server_request_call_delegate>(library); |
| 250 | this.grpcsharp_server_cancel_all_calls = GetMethodDelegate<Delegates.grpcsharp_server_cancel_all_calls_delegate>(library); |
| 251 | this.grpcsharp_server_shutdown_and_notify_callback = GetMethodDelegate<Delegates.grpcsharp_server_shutdown_and_notify_callback_delegate>(library); |
| 252 | this.grpcsharp_server_destroy = GetMethodDelegate<Delegates.grpcsharp_server_destroy_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 253 | |
Jan Tattermusch | c9b03fe | 2017-02-06 08:45:00 -0800 | [diff] [blame] | 254 | this.grpcsharp_call_auth_context = GetMethodDelegate<Delegates.grpcsharp_call_auth_context_delegate>(library); |
| 255 | this.grpcsharp_auth_context_peer_identity_property_name = GetMethodDelegate<Delegates.grpcsharp_auth_context_peer_identity_property_name_delegate>(library); |
| 256 | this.grpcsharp_auth_context_property_iterator = GetMethodDelegate<Delegates.grpcsharp_auth_context_property_iterator_delegate>(library); |
| 257 | this.grpcsharp_auth_property_iterator_next = GetMethodDelegate<Delegates.grpcsharp_auth_property_iterator_next_delegate>(library); |
| 258 | this.grpcsharp_auth_context_release = GetMethodDelegate<Delegates.grpcsharp_auth_context_release_delegate>(library); |
| 259 | |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 260 | this.gprsharp_now = GetMethodDelegate<Delegates.gprsharp_now_delegate>(library); |
| 261 | this.gprsharp_inf_future = GetMethodDelegate<Delegates.gprsharp_inf_future_delegate>(library); |
| 262 | this.gprsharp_inf_past = GetMethodDelegate<Delegates.gprsharp_inf_past_delegate>(library); |
| 263 | this.gprsharp_convert_clock_type = GetMethodDelegate<Delegates.gprsharp_convert_clock_type_delegate>(library); |
| 264 | this.gprsharp_sizeof_timespec = GetMethodDelegate<Delegates.gprsharp_sizeof_timespec_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 265 | |
Jon Skeet | 3fcd20f | 2016-07-08 14:38:39 +0100 | [diff] [blame] | 266 | this.grpcsharp_test_callback = GetMethodDelegate<Delegates.grpcsharp_test_callback_delegate>(library); |
| 267 | this.grpcsharp_test_nop = GetMethodDelegate<Delegates.grpcsharp_test_nop_delegate>(library); |
Jan Tattermusch | 645ae74 | 2017-05-22 08:46:26 -0700 | [diff] [blame] | 268 | this.grpcsharp_test_override_method = GetMethodDelegate<Delegates.grpcsharp_test_override_method_delegate>(library); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | /// <summary> |
| 272 | /// Gets singleton instance of this class. |
| 273 | /// </summary> |
| 274 | public static NativeMethods Get() |
| 275 | { |
| 276 | return NativeExtension.Get().NativeMethods; |
| 277 | } |
| 278 | |
| 279 | static T GetMethodDelegate<T>(UnmanagedLibrary library) |
| 280 | where T : class |
| 281 | { |
| 282 | var methodName = RemoveStringSuffix(typeof(T).Name, "_delegate"); |
| 283 | return library.GetNativeMethodDelegate<T>(methodName); |
| 284 | } |
| 285 | |
| 286 | static string RemoveStringSuffix(string str, string toRemove) |
| 287 | { |
| 288 | if (!str.EndsWith(toRemove)) |
| 289 | { |
| 290 | return str; |
| 291 | } |
| 292 | return str.Substring(0, str.Length - toRemove.Length); |
| 293 | } |
| 294 | |
| 295 | /// <summary> |
| 296 | /// Delegate types for all published native methods. Declared under inner class to prevent scope pollution. |
| 297 | /// </summary> |
| 298 | public class Delegates |
| 299 | { |
| 300 | public delegate void grpcsharp_init_delegate(); |
| 301 | public delegate void grpcsharp_shutdown_delegate(); |
| 302 | public delegate IntPtr grpcsharp_version_string_delegate(); // returns not-owned const char* |
| 303 | |
| 304 | public delegate BatchContextSafeHandle grpcsharp_batch_context_create_delegate(); |
| 305 | public delegate IntPtr grpcsharp_batch_context_recv_initial_metadata_delegate(BatchContextSafeHandle ctx); |
| 306 | public delegate IntPtr grpcsharp_batch_context_recv_message_length_delegate(BatchContextSafeHandle ctx); |
| 307 | public delegate void grpcsharp_batch_context_recv_message_to_buffer_delegate(BatchContextSafeHandle ctx, byte[] buffer, UIntPtr bufferLen); |
| 308 | public delegate StatusCode grpcsharp_batch_context_recv_status_on_client_status_delegate(BatchContextSafeHandle ctx); |
Craig Tiller | 7c70b6c | 2017-01-23 07:48:42 -0800 | [diff] [blame] | 309 | public delegate IntPtr grpcsharp_batch_context_recv_status_on_client_details_delegate(BatchContextSafeHandle ctx, out UIntPtr detailsLength); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 310 | public delegate IntPtr grpcsharp_batch_context_recv_status_on_client_trailing_metadata_delegate(BatchContextSafeHandle ctx); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 311 | public delegate int grpcsharp_batch_context_recv_close_on_server_cancelled_delegate(BatchContextSafeHandle ctx); |
| 312 | public delegate void grpcsharp_batch_context_destroy_delegate(IntPtr ctx); |
| 313 | |
Jan Tattermusch | 6e90171 | 2016-10-21 00:42:37 +0200 | [diff] [blame] | 314 | public delegate RequestCallContextSafeHandle grpcsharp_request_call_context_create_delegate(); |
| 315 | public delegate CallSafeHandle grpcsharp_request_call_context_call_delegate(RequestCallContextSafeHandle ctx); |
Craig Tiller | 7c70b6c | 2017-01-23 07:48:42 -0800 | [diff] [blame] | 316 | public delegate IntPtr grpcsharp_request_call_context_method_delegate(RequestCallContextSafeHandle ctx, out UIntPtr methodLength); |
| 317 | public delegate IntPtr grpcsharp_request_call_context_host_delegate(RequestCallContextSafeHandle ctx, out UIntPtr hostLength); |
Jan Tattermusch | 6e90171 | 2016-10-21 00:42:37 +0200 | [diff] [blame] | 318 | public delegate Timespec grpcsharp_request_call_context_deadline_delegate(RequestCallContextSafeHandle ctx); |
| 319 | public delegate IntPtr grpcsharp_request_call_context_request_metadata_delegate(RequestCallContextSafeHandle ctx); |
| 320 | public delegate void grpcsharp_request_call_context_destroy_delegate(IntPtr ctx); |
| 321 | |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 322 | public delegate CallCredentialsSafeHandle grpcsharp_composite_call_credentials_create_delegate(CallCredentialsSafeHandle creds1, CallCredentialsSafeHandle creds2); |
| 323 | public delegate void grpcsharp_call_credentials_release_delegate(IntPtr credentials); |
| 324 | |
Jan Tattermusch | e0af286 | 2016-05-18 21:02:03 -0700 | [diff] [blame] | 325 | public delegate CallError grpcsharp_call_cancel_delegate(CallSafeHandle call); |
| 326 | public delegate CallError grpcsharp_call_cancel_with_status_delegate(CallSafeHandle call, StatusCode status, string description); |
| 327 | public delegate CallError grpcsharp_call_start_unary_delegate(CallSafeHandle call, |
Jan Tattermusch | 43416da | 2016-11-22 17:28:22 +0100 | [diff] [blame] | 328 | BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); |
Jan Tattermusch | e0af286 | 2016-05-18 21:02:03 -0700 | [diff] [blame] | 329 | public delegate CallError grpcsharp_call_start_client_streaming_delegate(CallSafeHandle call, |
Jan Tattermusch | 43416da | 2016-11-22 17:28:22 +0100 | [diff] [blame] | 330 | BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); |
Jan Tattermusch | e0af286 | 2016-05-18 21:02:03 -0700 | [diff] [blame] | 331 | public delegate CallError grpcsharp_call_start_server_streaming_delegate(CallSafeHandle call, |
Jan Tattermusch | 43416da | 2016-11-22 17:28:22 +0100 | [diff] [blame] | 332 | BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, |
| 333 | MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); |
Jan Tattermusch | e0af286 | 2016-05-18 21:02:03 -0700 | [diff] [blame] | 334 | public delegate CallError grpcsharp_call_start_duplex_streaming_delegate(CallSafeHandle call, |
Jan Tattermusch | 43416da | 2016-11-22 17:28:22 +0100 | [diff] [blame] | 335 | BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags); |
Jan Tattermusch | e0af286 | 2016-05-18 21:02:03 -0700 | [diff] [blame] | 336 | public delegate CallError grpcsharp_call_send_message_delegate(CallSafeHandle call, |
Jan Tattermusch | 719d373 | 2017-05-16 20:18:27 +0200 | [diff] [blame] | 337 | BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, int sendEmptyInitialMetadata); |
Jan Tattermusch | e0af286 | 2016-05-18 21:02:03 -0700 | [diff] [blame] | 338 | public delegate CallError grpcsharp_call_send_close_from_client_delegate(CallSafeHandle call, |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 339 | BatchContextSafeHandle ctx); |
Jan Tattermusch | e0af286 | 2016-05-18 21:02:03 -0700 | [diff] [blame] | 340 | public delegate CallError grpcsharp_call_send_status_from_server_delegate(CallSafeHandle call, |
Jan Tattermusch | 719d373 | 2017-05-16 20:18:27 +0200 | [diff] [blame] | 341 | BatchContextSafeHandle ctx, StatusCode statusCode, byte[] statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, |
Jan Tattermusch | 305ffd4 | 2016-05-04 10:26:24 -0700 | [diff] [blame] | 342 | byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); |
Jan Tattermusch | e0af286 | 2016-05-18 21:02:03 -0700 | [diff] [blame] | 343 | public delegate CallError grpcsharp_call_recv_message_delegate(CallSafeHandle call, |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 344 | BatchContextSafeHandle ctx); |
Jan Tattermusch | e0af286 | 2016-05-18 21:02:03 -0700 | [diff] [blame] | 345 | public delegate CallError grpcsharp_call_recv_initial_metadata_delegate(CallSafeHandle call, |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 346 | BatchContextSafeHandle ctx); |
Jan Tattermusch | e0af286 | 2016-05-18 21:02:03 -0700 | [diff] [blame] | 347 | public delegate CallError grpcsharp_call_start_serverside_delegate(CallSafeHandle call, |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 348 | BatchContextSafeHandle ctx); |
Jan Tattermusch | e0af286 | 2016-05-18 21:02:03 -0700 | [diff] [blame] | 349 | public delegate CallError grpcsharp_call_send_initial_metadata_delegate(CallSafeHandle call, |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 350 | BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray); |
Jan Tattermusch | e0af286 | 2016-05-18 21:02:03 -0700 | [diff] [blame] | 351 | public delegate CallError grpcsharp_call_set_credentials_delegate(CallSafeHandle call, CallCredentialsSafeHandle credentials); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 352 | public delegate CStringSafeHandle grpcsharp_call_get_peer_delegate(CallSafeHandle call); |
| 353 | public delegate void grpcsharp_call_destroy_delegate(IntPtr call); |
| 354 | |
| 355 | public delegate ChannelArgsSafeHandle grpcsharp_channel_args_create_delegate(UIntPtr numArgs); |
| 356 | public delegate void grpcsharp_channel_args_set_string_delegate(ChannelArgsSafeHandle args, UIntPtr index, string key, string value); |
| 357 | public delegate void grpcsharp_channel_args_set_integer_delegate(ChannelArgsSafeHandle args, UIntPtr index, string key, int value); |
| 358 | public delegate void grpcsharp_channel_args_destroy_delegate(IntPtr args); |
| 359 | |
Jan Tattermusch | 660c15b | 2016-02-02 06:39:10 -0800 | [diff] [blame] | 360 | public delegate void grpcsharp_override_default_ssl_roots(string pemRootCerts); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 361 | public delegate ChannelCredentialsSafeHandle grpcsharp_ssl_credentials_create_delegate(string pemRootCerts, string keyCertPairCertChain, string keyCertPairPrivateKey); |
| 362 | public delegate ChannelCredentialsSafeHandle grpcsharp_composite_channel_credentials_create_delegate(ChannelCredentialsSafeHandle channelCreds, CallCredentialsSafeHandle callCreds); |
| 363 | public delegate void grpcsharp_channel_credentials_release_delegate(IntPtr credentials); |
| 364 | |
| 365 | public delegate ChannelSafeHandle grpcsharp_insecure_channel_create_delegate(string target, ChannelArgsSafeHandle channelArgs); |
| 366 | public delegate ChannelSafeHandle grpcsharp_secure_channel_create_delegate(ChannelCredentialsSafeHandle credentials, string target, ChannelArgsSafeHandle channelArgs); |
| 367 | public delegate CallSafeHandle grpcsharp_channel_create_call_delegate(ChannelSafeHandle channel, CallSafeHandle parentCall, ContextPropagationFlags propagationMask, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline); |
| 368 | public delegate ChannelState grpcsharp_channel_check_connectivity_state_delegate(ChannelSafeHandle channel, int tryToConnect); |
| 369 | public delegate void grpcsharp_channel_watch_connectivity_state_delegate(ChannelSafeHandle channel, ChannelState lastObservedState, |
| 370 | Timespec deadline, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx); |
| 371 | public delegate CStringSafeHandle grpcsharp_channel_get_target_delegate(ChannelSafeHandle call); |
| 372 | public delegate void grpcsharp_channel_destroy_delegate(IntPtr channel); |
| 373 | |
| 374 | public delegate int grpcsharp_sizeof_grpc_event_delegate(); |
| 375 | |
Jan Tattermusch | b746294 | 2017-03-08 19:30:21 +0100 | [diff] [blame] | 376 | public delegate CompletionQueueSafeHandle grpcsharp_completion_queue_create_async_delegate(); |
| 377 | public delegate CompletionQueueSafeHandle grpcsharp_completion_queue_create_sync_delegate(); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 378 | public delegate void grpcsharp_completion_queue_shutdown_delegate(CompletionQueueSafeHandle cq); |
| 379 | public delegate CompletionQueueEvent grpcsharp_completion_queue_next_delegate(CompletionQueueSafeHandle cq); |
| 380 | public delegate CompletionQueueEvent grpcsharp_completion_queue_pluck_delegate(CompletionQueueSafeHandle cq, IntPtr tag); |
| 381 | public delegate void grpcsharp_completion_queue_destroy_delegate(IntPtr cq); |
| 382 | |
| 383 | public delegate void gprsharp_free_delegate(IntPtr ptr); |
| 384 | |
| 385 | public delegate MetadataArraySafeHandle grpcsharp_metadata_array_create_delegate(UIntPtr capacity); |
| 386 | public delegate void grpcsharp_metadata_array_add_delegate(MetadataArraySafeHandle array, string key, byte[] value, UIntPtr valueLength); |
| 387 | public delegate UIntPtr grpcsharp_metadata_array_count_delegate(IntPtr metadataArray); |
Craig Tiller | 7c70b6c | 2017-01-23 07:48:42 -0800 | [diff] [blame] | 388 | public delegate IntPtr grpcsharp_metadata_array_get_key_delegate(IntPtr metadataArray, UIntPtr index, out UIntPtr keyLength); |
| 389 | public delegate IntPtr grpcsharp_metadata_array_get_value_delegate(IntPtr metadataArray, UIntPtr index, out UIntPtr valueLength); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 390 | public delegate void grpcsharp_metadata_array_destroy_full_delegate(IntPtr array); |
| 391 | |
| 392 | public delegate void grpcsharp_redirect_log_delegate(GprLogDelegate callback); |
| 393 | |
| 394 | public delegate CallCredentialsSafeHandle grpcsharp_metadata_credentials_create_from_plugin_delegate(NativeMetadataInterceptor interceptor); |
| 395 | public delegate void grpcsharp_metadata_credentials_notify_from_plugin_delegate(IntPtr callbackPtr, IntPtr userData, MetadataArraySafeHandle metadataArray, StatusCode statusCode, string errorDetails); |
| 396 | |
Jan Tattermusch | 719d373 | 2017-05-16 20:18:27 +0200 | [diff] [blame] | 397 | public delegate ServerCredentialsSafeHandle grpcsharp_ssl_server_credentials_create_delegate(string pemRootCerts, string[] keyCertPairCertChainArray, string[] keyCertPairPrivateKeyArray, UIntPtr numKeyCertPairs, int forceClientAuth); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 398 | public delegate void grpcsharp_server_credentials_release_delegate(IntPtr credentials); |
| 399 | |
Jan Tattermusch | 5ee8e77 | 2016-05-24 16:17:10 -0400 | [diff] [blame] | 400 | public delegate ServerSafeHandle grpcsharp_server_create_delegate(ChannelArgsSafeHandle args); |
| 401 | public delegate void grpcsharp_server_register_completion_queue_delegate(ServerSafeHandle server, CompletionQueueSafeHandle cq); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 402 | public delegate int grpcsharp_server_add_insecure_http2_port_delegate(ServerSafeHandle server, string addr); |
| 403 | public delegate int grpcsharp_server_add_secure_http2_port_delegate(ServerSafeHandle server, string addr, ServerCredentialsSafeHandle creds); |
| 404 | public delegate void grpcsharp_server_start_delegate(ServerSafeHandle server); |
Jan Tattermusch | 6e90171 | 2016-10-21 00:42:37 +0200 | [diff] [blame] | 405 | public delegate CallError grpcsharp_server_request_call_delegate(ServerSafeHandle server, CompletionQueueSafeHandle cq, RequestCallContextSafeHandle ctx); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 406 | public delegate void grpcsharp_server_cancel_all_calls_delegate(ServerSafeHandle server); |
| 407 | public delegate void grpcsharp_server_shutdown_and_notify_callback_delegate(ServerSafeHandle server, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx); |
| 408 | public delegate void grpcsharp_server_destroy_delegate(IntPtr server); |
| 409 | |
Jan Tattermusch | c9b03fe | 2017-02-06 08:45:00 -0800 | [diff] [blame] | 410 | public delegate AuthContextSafeHandle grpcsharp_call_auth_context_delegate(CallSafeHandle call); |
| 411 | public delegate IntPtr grpcsharp_auth_context_peer_identity_property_name_delegate(AuthContextSafeHandle authContext); // returns const char* |
| 412 | public delegate AuthContextSafeHandle.NativeAuthPropertyIterator grpcsharp_auth_context_property_iterator_delegate(AuthContextSafeHandle authContext); |
| 413 | public delegate IntPtr grpcsharp_auth_property_iterator_next_delegate(ref AuthContextSafeHandle.NativeAuthPropertyIterator iterator); // returns const auth_property* |
| 414 | public delegate void grpcsharp_auth_context_release_delegate(IntPtr authContext); |
| 415 | |
Jan Tattermusch | e0af286 | 2016-05-18 21:02:03 -0700 | [diff] [blame] | 416 | public delegate Timespec gprsharp_now_delegate(ClockType clockType); |
| 417 | public delegate Timespec gprsharp_inf_future_delegate(ClockType clockType); |
| 418 | public delegate Timespec gprsharp_inf_past_delegate(ClockType clockType); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 419 | |
Jan Tattermusch | e0af286 | 2016-05-18 21:02:03 -0700 | [diff] [blame] | 420 | public delegate Timespec gprsharp_convert_clock_type_delegate(Timespec t, ClockType targetClock); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 421 | public delegate int gprsharp_sizeof_timespec_delegate(); |
| 422 | |
Jan Tattermusch | e0af286 | 2016-05-18 21:02:03 -0700 | [diff] [blame] | 423 | public delegate CallError grpcsharp_test_callback_delegate([MarshalAs(UnmanagedType.FunctionPtr)] OpCompletionDelegate callback); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 424 | public delegate IntPtr grpcsharp_test_nop_delegate(IntPtr ptr); |
Jan Tattermusch | 7c206f4 | 2017-05-22 09:23:18 -0700 | [diff] [blame] | 425 | public delegate void grpcsharp_test_override_method_delegate(string methodName, string variant); |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 426 | } |
Jan Tattermusch | afab541 | 2016-01-12 17:57:25 -0800 | [diff] [blame] | 427 | } |
| 428 | } |