| <%def name="get_native_methods()"><% |
| native_method_signatures = [ |
| 'void grpcsharp_init()', |
| 'void grpcsharp_shutdown()', |
| 'IntPtr grpcsharp_version_string() // returns not-owned const char*', |
| 'BatchContextSafeHandle grpcsharp_batch_context_create()', |
| 'IntPtr grpcsharp_batch_context_recv_initial_metadata(BatchContextSafeHandle ctx)', |
| 'IntPtr grpcsharp_batch_context_recv_message_length(BatchContextSafeHandle ctx)', |
| 'int grpcsharp_batch_context_recv_message_next_slice_peek(BatchContextSafeHandle ctx, out UIntPtr sliceLen, out IntPtr sliceDataPtr)', |
| 'StatusCode grpcsharp_batch_context_recv_status_on_client_status(BatchContextSafeHandle ctx)', |
| 'IntPtr grpcsharp_batch_context_recv_status_on_client_details(BatchContextSafeHandle ctx, out UIntPtr detailsLength)', |
| 'IntPtr grpcsharp_batch_context_recv_status_on_client_trailing_metadata(BatchContextSafeHandle ctx)', |
| 'int grpcsharp_batch_context_recv_close_on_server_cancelled(BatchContextSafeHandle ctx)', |
| 'void grpcsharp_batch_context_reset(BatchContextSafeHandle ctx)', |
| 'void grpcsharp_batch_context_destroy(IntPtr ctx)', |
| 'RequestCallContextSafeHandle grpcsharp_request_call_context_create()', |
| 'CallSafeHandle grpcsharp_request_call_context_call(RequestCallContextSafeHandle ctx)', |
| 'IntPtr grpcsharp_request_call_context_method(RequestCallContextSafeHandle ctx, out UIntPtr methodLength)', |
| 'IntPtr grpcsharp_request_call_context_host(RequestCallContextSafeHandle ctx, out UIntPtr hostLength)', |
| 'Timespec grpcsharp_request_call_context_deadline(RequestCallContextSafeHandle ctx)', |
| 'IntPtr grpcsharp_request_call_context_request_metadata(RequestCallContextSafeHandle ctx)', |
| 'void grpcsharp_request_call_context_reset(RequestCallContextSafeHandle ctx)', |
| 'void grpcsharp_request_call_context_destroy(IntPtr ctx)', |
| 'CallCredentialsSafeHandle grpcsharp_composite_call_credentials_create(CallCredentialsSafeHandle creds1, CallCredentialsSafeHandle creds2)', |
| 'void grpcsharp_call_credentials_release(IntPtr credentials)', |
| 'CallError grpcsharp_call_cancel(CallSafeHandle call)', |
| 'CallError grpcsharp_call_cancel_with_status(CallSafeHandle call, StatusCode status, string description)', |
| 'CallError grpcsharp_call_start_unary(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', |
| 'CallError grpcsharp_call_start_client_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', |
| 'CallError grpcsharp_call_start_server_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', |
| 'CallError grpcsharp_call_start_duplex_streaming(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray, CallFlags metadataFlags)', |
| 'CallError grpcsharp_call_send_message(CallSafeHandle call, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, int sendEmptyInitialMetadata)', |
| 'CallError grpcsharp_call_send_close_from_client(CallSafeHandle call, BatchContextSafeHandle ctx)', |
| 'CallError grpcsharp_call_send_status_from_server(CallSafeHandle call, BatchContextSafeHandle ctx, StatusCode statusCode, byte[] statusMessage, UIntPtr statusMessageLen, MetadataArraySafeHandle metadataArray, int sendEmptyInitialMetadata, byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags)', |
| 'CallError grpcsharp_call_recv_message(CallSafeHandle call, BatchContextSafeHandle ctx)', |
| 'CallError grpcsharp_call_recv_initial_metadata(CallSafeHandle call, BatchContextSafeHandle ctx)', |
| 'CallError grpcsharp_call_start_serverside(CallSafeHandle call, BatchContextSafeHandle ctx)', |
| 'CallError grpcsharp_call_send_initial_metadata(CallSafeHandle call, BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray)', |
| 'CallError grpcsharp_call_set_credentials(CallSafeHandle call, CallCredentialsSafeHandle credentials)', |
| 'CStringSafeHandle grpcsharp_call_get_peer(CallSafeHandle call)', |
| 'void grpcsharp_call_destroy(IntPtr call)', |
| 'ChannelArgsSafeHandle grpcsharp_channel_args_create(UIntPtr numArgs)', |
| 'void grpcsharp_channel_args_set_string(ChannelArgsSafeHandle args, UIntPtr index, string key, string value)', |
| 'void grpcsharp_channel_args_set_integer(ChannelArgsSafeHandle args, UIntPtr index, string key, int value)', |
| 'void grpcsharp_channel_args_destroy(IntPtr args)', |
| 'void grpcsharp_override_default_ssl_roots(string pemRootCerts)', |
| 'ChannelCredentialsSafeHandle grpcsharp_ssl_credentials_create(string pemRootCerts, string keyCertPairCertChain, string keyCertPairPrivateKey, IntPtr verifyPeerCallbackTag)', |
| 'ChannelCredentialsSafeHandle grpcsharp_composite_channel_credentials_create(ChannelCredentialsSafeHandle channelCreds, CallCredentialsSafeHandle callCreds)', |
| 'void grpcsharp_channel_credentials_release(IntPtr credentials)', |
| 'ChannelSafeHandle grpcsharp_insecure_channel_create(string target, ChannelArgsSafeHandle channelArgs)', |
| 'ChannelSafeHandle grpcsharp_secure_channel_create(ChannelCredentialsSafeHandle credentials, string target, ChannelArgsSafeHandle channelArgs)', |
| 'CallSafeHandle grpcsharp_channel_create_call(ChannelSafeHandle channel, CallSafeHandle parentCall, ContextPropagationFlags propagationMask, CompletionQueueSafeHandle cq, string method, string host, Timespec deadline)', |
| 'ChannelState grpcsharp_channel_check_connectivity_state(ChannelSafeHandle channel, int tryToConnect)', |
| 'void grpcsharp_channel_watch_connectivity_state(ChannelSafeHandle channel, ChannelState lastObservedState, Timespec deadline, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx)', |
| 'CStringSafeHandle grpcsharp_channel_get_target(ChannelSafeHandle call)', |
| 'void grpcsharp_channel_destroy(IntPtr channel)', |
| 'int grpcsharp_sizeof_grpc_event()', |
| 'CompletionQueueSafeHandle grpcsharp_completion_queue_create_async()', |
| 'CompletionQueueSafeHandle grpcsharp_completion_queue_create_sync()', |
| 'void grpcsharp_completion_queue_shutdown(CompletionQueueSafeHandle cq)', |
| 'CompletionQueueEvent grpcsharp_completion_queue_next(CompletionQueueSafeHandle cq)', |
| 'CompletionQueueEvent grpcsharp_completion_queue_pluck(CompletionQueueSafeHandle cq, IntPtr tag)', |
| 'void grpcsharp_completion_queue_destroy(IntPtr cq)', |
| 'void gprsharp_free(IntPtr ptr)', |
| 'MetadataArraySafeHandle grpcsharp_metadata_array_create(UIntPtr capacity)', |
| 'void grpcsharp_metadata_array_add(MetadataArraySafeHandle array, string key, byte[] value, UIntPtr valueLength)', |
| 'UIntPtr grpcsharp_metadata_array_count(IntPtr metadataArray)', |
| 'IntPtr grpcsharp_metadata_array_get_key(IntPtr metadataArray, UIntPtr index, out UIntPtr keyLength)', |
| 'IntPtr grpcsharp_metadata_array_get_value(IntPtr metadataArray, UIntPtr index, out UIntPtr valueLength)', |
| 'void grpcsharp_metadata_array_destroy_full(IntPtr array)', |
| 'void grpcsharp_redirect_log(GprLogDelegate callback)', |
| 'void grpcsharp_native_callback_dispatcher_init(NativeCallbackDispatcherCallback dispatcher)', |
| 'CallCredentialsSafeHandle grpcsharp_metadata_credentials_create_from_plugin(IntPtr nativeCallbackTag)', |
| 'void grpcsharp_metadata_credentials_notify_from_plugin(IntPtr callbackPtr, IntPtr userData, MetadataArraySafeHandle metadataArray, StatusCode statusCode, string errorDetails)', |
| 'ServerCredentialsSafeHandle grpcsharp_ssl_server_credentials_create(string pemRootCerts, string[] keyCertPairCertChainArray, string[] keyCertPairPrivateKeyArray, UIntPtr numKeyCertPairs, SslClientCertificateRequestType clientCertificateRequest)', |
| 'void grpcsharp_server_credentials_release(IntPtr credentials)', |
| 'ServerSafeHandle grpcsharp_server_create(ChannelArgsSafeHandle args)', |
| 'void grpcsharp_server_register_completion_queue(ServerSafeHandle server, CompletionQueueSafeHandle cq)', |
| 'int grpcsharp_server_add_insecure_http2_port(ServerSafeHandle server, string addr)', |
| 'int grpcsharp_server_add_secure_http2_port(ServerSafeHandle server, string addr, ServerCredentialsSafeHandle creds)', |
| 'void grpcsharp_server_start(ServerSafeHandle server)', |
| 'CallError grpcsharp_server_request_call(ServerSafeHandle server, CompletionQueueSafeHandle cq, RequestCallContextSafeHandle ctx)', |
| 'void grpcsharp_server_cancel_all_calls(ServerSafeHandle server)', |
| 'void grpcsharp_server_shutdown_and_notify_callback(ServerSafeHandle server, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx)', |
| 'void grpcsharp_server_destroy(IntPtr server)', |
| 'AuthContextSafeHandle grpcsharp_call_auth_context(CallSafeHandle call)', |
| 'IntPtr grpcsharp_auth_context_peer_identity_property_name(AuthContextSafeHandle authContext) // returns const char*', |
| 'AuthContextSafeHandle.NativeAuthPropertyIterator grpcsharp_auth_context_property_iterator(AuthContextSafeHandle authContext)', |
| 'IntPtr grpcsharp_auth_property_iterator_next(ref AuthContextSafeHandle.NativeAuthPropertyIterator iterator) // returns const auth_property*', |
| 'void grpcsharp_auth_context_release(IntPtr authContext)', |
| 'Timespec gprsharp_now(ClockType clockType)', |
| 'Timespec gprsharp_inf_future(ClockType clockType)', |
| 'Timespec gprsharp_inf_past(ClockType clockType)', |
| 'Timespec gprsharp_convert_clock_type(Timespec t, ClockType targetClock)', |
| 'int gprsharp_sizeof_timespec()', |
| 'CallError grpcsharp_test_callback([MarshalAs(UnmanagedType.FunctionPtr)] NativeCallbackTestDelegate callback)', |
| 'IntPtr grpcsharp_test_nop(IntPtr ptr)', |
| 'void grpcsharp_test_override_method(string methodName, string variant)', |
| ] |
| |
| import re |
| native_methods = [] |
| for signature in native_method_signatures: |
| match = re.match('([A-Za-z0-9_.]+) +([A-Za-z0-9_]+)\\((.*)\\)(.*)', signature) |
| if not match: |
| raise Exception('Malformed signature "%s"' % signature) |
| native_methods.append({'returntype': match.group(1), 'name': match.group(2), 'params': match.group(3), 'comment': match.group(4)}) |
| |
| return list(native_methods) |
| %></%def> |