IBufferWriter: tests now passing with a hack

pull/19792/head
Jan Tattermusch 5 years ago
parent 988ca514b9
commit 36e46234f7
  1. 2
      src/csharp/Grpc.Core/Internal/AsyncCallBase.cs
  2. 22
      src/csharp/Grpc.Core/Internal/NativeMethods.Generated.cs
  3. 17
      src/csharp/ext/grpc_csharp_ext.c
  4. 8
      src/csharp/unitypackage/unitypackage_skeleton/Plugins/Grpc.Core/runtimes/grpc_csharp_ext_dummy_stubs.c
  5. 2
      templates/src/csharp/Grpc.Core/Internal/native_methods.include

@ -220,7 +220,7 @@ namespace Grpc.Core.Internal
{ {
context = DefaultSerializationContext.GetInitializedThreadLocal(); context = DefaultSerializationContext.GetInitializedThreadLocal();
serializer(msg, context); serializer(msg, context);
return context.GetPayload(); return context.GetPayload().GetPayload();
} }
finally finally
{ {

@ -124,6 +124,8 @@ namespace Grpc.Core.Internal
public readonly Delegates.grpcsharp_auth_context_release_delegate grpcsharp_auth_context_release; public readonly Delegates.grpcsharp_auth_context_release_delegate grpcsharp_auth_context_release;
public readonly Delegates.grpcsharp_slice_buffer_create_delegate grpcsharp_slice_buffer_create; public readonly Delegates.grpcsharp_slice_buffer_create_delegate grpcsharp_slice_buffer_create;
public readonly Delegates.grpcsharp_slice_buffer_adjust_tail_space_delegate grpcsharp_slice_buffer_adjust_tail_space; public readonly Delegates.grpcsharp_slice_buffer_adjust_tail_space_delegate grpcsharp_slice_buffer_adjust_tail_space;
public readonly Delegates.grpcsharp_slice_buffer_slice_count_delegate grpcsharp_slice_buffer_slice_count;
public readonly Delegates.grpcsharp_slice_buffer_slice_peek_delegate grpcsharp_slice_buffer_slice_peek;
public readonly Delegates.grpcsharp_slice_buffer_destroy_delegate grpcsharp_slice_buffer_destroy; public readonly Delegates.grpcsharp_slice_buffer_destroy_delegate grpcsharp_slice_buffer_destroy;
public readonly Delegates.gprsharp_now_delegate gprsharp_now; public readonly Delegates.gprsharp_now_delegate gprsharp_now;
public readonly Delegates.gprsharp_inf_future_delegate gprsharp_inf_future; public readonly Delegates.gprsharp_inf_future_delegate gprsharp_inf_future;
@ -229,6 +231,8 @@ namespace Grpc.Core.Internal
this.grpcsharp_auth_context_release = GetMethodDelegate<Delegates.grpcsharp_auth_context_release_delegate>(library); this.grpcsharp_auth_context_release = GetMethodDelegate<Delegates.grpcsharp_auth_context_release_delegate>(library);
this.grpcsharp_slice_buffer_create = GetMethodDelegate<Delegates.grpcsharp_slice_buffer_create_delegate>(library); this.grpcsharp_slice_buffer_create = GetMethodDelegate<Delegates.grpcsharp_slice_buffer_create_delegate>(library);
this.grpcsharp_slice_buffer_adjust_tail_space = GetMethodDelegate<Delegates.grpcsharp_slice_buffer_adjust_tail_space_delegate>(library); this.grpcsharp_slice_buffer_adjust_tail_space = GetMethodDelegate<Delegates.grpcsharp_slice_buffer_adjust_tail_space_delegate>(library);
this.grpcsharp_slice_buffer_slice_count = GetMethodDelegate<Delegates.grpcsharp_slice_buffer_slice_count_delegate>(library);
this.grpcsharp_slice_buffer_slice_peek = GetMethodDelegate<Delegates.grpcsharp_slice_buffer_slice_peek_delegate>(library);
this.grpcsharp_slice_buffer_destroy = GetMethodDelegate<Delegates.grpcsharp_slice_buffer_destroy_delegate>(library); this.grpcsharp_slice_buffer_destroy = GetMethodDelegate<Delegates.grpcsharp_slice_buffer_destroy_delegate>(library);
this.gprsharp_now = GetMethodDelegate<Delegates.gprsharp_now_delegate>(library); this.gprsharp_now = GetMethodDelegate<Delegates.gprsharp_now_delegate>(library);
this.gprsharp_inf_future = GetMethodDelegate<Delegates.gprsharp_inf_future_delegate>(library); this.gprsharp_inf_future = GetMethodDelegate<Delegates.gprsharp_inf_future_delegate>(library);
@ -333,6 +337,8 @@ namespace Grpc.Core.Internal
this.grpcsharp_auth_context_release = DllImportsFromStaticLib.grpcsharp_auth_context_release; this.grpcsharp_auth_context_release = DllImportsFromStaticLib.grpcsharp_auth_context_release;
this.grpcsharp_slice_buffer_create = DllImportsFromStaticLib.grpcsharp_slice_buffer_create; this.grpcsharp_slice_buffer_create = DllImportsFromStaticLib.grpcsharp_slice_buffer_create;
this.grpcsharp_slice_buffer_adjust_tail_space = DllImportsFromStaticLib.grpcsharp_slice_buffer_adjust_tail_space; this.grpcsharp_slice_buffer_adjust_tail_space = DllImportsFromStaticLib.grpcsharp_slice_buffer_adjust_tail_space;
this.grpcsharp_slice_buffer_slice_count = DllImportsFromStaticLib.grpcsharp_slice_buffer_slice_count;
this.grpcsharp_slice_buffer_slice_peek = DllImportsFromStaticLib.grpcsharp_slice_buffer_slice_peek;
this.grpcsharp_slice_buffer_destroy = DllImportsFromStaticLib.grpcsharp_slice_buffer_destroy; this.grpcsharp_slice_buffer_destroy = DllImportsFromStaticLib.grpcsharp_slice_buffer_destroy;
this.gprsharp_now = DllImportsFromStaticLib.gprsharp_now; this.gprsharp_now = DllImportsFromStaticLib.gprsharp_now;
this.gprsharp_inf_future = DllImportsFromStaticLib.gprsharp_inf_future; this.gprsharp_inf_future = DllImportsFromStaticLib.gprsharp_inf_future;
@ -437,6 +443,8 @@ namespace Grpc.Core.Internal
this.grpcsharp_auth_context_release = DllImportsFromSharedLib.grpcsharp_auth_context_release; this.grpcsharp_auth_context_release = DllImportsFromSharedLib.grpcsharp_auth_context_release;
this.grpcsharp_slice_buffer_create = DllImportsFromSharedLib.grpcsharp_slice_buffer_create; this.grpcsharp_slice_buffer_create = DllImportsFromSharedLib.grpcsharp_slice_buffer_create;
this.grpcsharp_slice_buffer_adjust_tail_space = DllImportsFromSharedLib.grpcsharp_slice_buffer_adjust_tail_space; this.grpcsharp_slice_buffer_adjust_tail_space = DllImportsFromSharedLib.grpcsharp_slice_buffer_adjust_tail_space;
this.grpcsharp_slice_buffer_slice_count = DllImportsFromSharedLib.grpcsharp_slice_buffer_slice_count;
this.grpcsharp_slice_buffer_slice_peek = DllImportsFromSharedLib.grpcsharp_slice_buffer_slice_peek;
this.grpcsharp_slice_buffer_destroy = DllImportsFromSharedLib.grpcsharp_slice_buffer_destroy; this.grpcsharp_slice_buffer_destroy = DllImportsFromSharedLib.grpcsharp_slice_buffer_destroy;
this.gprsharp_now = DllImportsFromSharedLib.gprsharp_now; this.gprsharp_now = DllImportsFromSharedLib.gprsharp_now;
this.gprsharp_inf_future = DllImportsFromSharedLib.gprsharp_inf_future; this.gprsharp_inf_future = DllImportsFromSharedLib.gprsharp_inf_future;
@ -544,6 +552,8 @@ namespace Grpc.Core.Internal
public delegate void grpcsharp_auth_context_release_delegate(IntPtr authContext); public delegate void grpcsharp_auth_context_release_delegate(IntPtr authContext);
public delegate SliceBufferSafeHandle grpcsharp_slice_buffer_create_delegate(); public delegate SliceBufferSafeHandle grpcsharp_slice_buffer_create_delegate();
public delegate IntPtr grpcsharp_slice_buffer_adjust_tail_space_delegate(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); public delegate IntPtr grpcsharp_slice_buffer_adjust_tail_space_delegate(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace);
public delegate UIntPtr grpcsharp_slice_buffer_slice_count_delegate(SliceBufferSafeHandle sliceBuffer);
public delegate void grpcsharp_slice_buffer_slice_peek_delegate(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr);
public delegate void grpcsharp_slice_buffer_destroy_delegate(IntPtr sliceBuffer); public delegate void grpcsharp_slice_buffer_destroy_delegate(IntPtr sliceBuffer);
public delegate Timespec gprsharp_now_delegate(ClockType clockType); public delegate Timespec gprsharp_now_delegate(ClockType clockType);
public delegate Timespec gprsharp_inf_future_delegate(ClockType clockType); public delegate Timespec gprsharp_inf_future_delegate(ClockType clockType);
@ -833,6 +843,12 @@ namespace Grpc.Core.Internal
[DllImport(ImportName)] [DllImport(ImportName)]
public static extern IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); public static extern IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace);
[DllImport(ImportName)]
public static extern UIntPtr grpcsharp_slice_buffer_slice_count(SliceBufferSafeHandle sliceBuffer);
[DllImport(ImportName)]
public static extern void grpcsharp_slice_buffer_slice_peek(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr);
[DllImport(ImportName)] [DllImport(ImportName)]
public static extern void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer); public static extern void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer);
@ -1141,6 +1157,12 @@ namespace Grpc.Core.Internal
[DllImport(ImportName)] [DllImport(ImportName)]
public static extern IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace); public static extern IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace);
[DllImport(ImportName)]
public static extern UIntPtr grpcsharp_slice_buffer_slice_count(SliceBufferSafeHandle sliceBuffer);
[DllImport(ImportName)]
public static extern void grpcsharp_slice_buffer_slice_peek(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr);
[DllImport(ImportName)] [DllImport(ImportName)]
public static extern void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer); public static extern void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer);

@ -1196,6 +1196,19 @@ grpcsharp_slice_buffer_destroy(grpc_slice_buffer* buffer) {
gpr_free(buffer); gpr_free(buffer);
} }
GPR_EXPORT size_t GPR_CALLTYPE
grpcsharp_slice_buffer_slice_count(grpc_slice_buffer* buffer) {
return buffer->count;
}
GPR_EXPORT void GPR_CALLTYPE
grpcsharp_slice_buffer_slice_peek(grpc_slice_buffer* buffer, size_t index, size_t* slice_len, uint8_t** slice_data_ptr) {
GPR_ASSERT(buffer->count > index);
grpc_slice* slice_ptr = &buffer->slices[index];
*slice_len = GRPC_SLICE_LENGTH(*slice_ptr);
*slice_data_ptr = GRPC_SLICE_START_PTR(*slice_ptr);
}
GPR_EXPORT grpc_byte_buffer* GPR_CALLTYPE GPR_EXPORT grpc_byte_buffer* GPR_CALLTYPE
grpcsharp_create_byte_buffer_from_stolen_slices(grpc_slice_buffer* slice_buffer) { grpcsharp_create_byte_buffer_from_stolen_slices(grpc_slice_buffer* slice_buffer) {
grpc_byte_buffer* bb = grpc_byte_buffer* bb =
@ -1217,6 +1230,10 @@ GPR_EXPORT void* GPR_CALLTYPE
grpcsharp_slice_buffer_adjust_tail_space(grpc_slice_buffer* buffer, size_t available_tail_space, grpcsharp_slice_buffer_adjust_tail_space(grpc_slice_buffer* buffer, size_t available_tail_space,
size_t requested_tail_space) { size_t requested_tail_space) {
if (available_tail_space == 0 && requested_tail_space == 0)
{
return NULL;
}
// TODO: what if available_tail_space == requested_tail_space == 0 // TODO: what if available_tail_space == requested_tail_space == 0
if (available_tail_space >= requested_tail_space) if (available_tail_space >= requested_tail_space)

@ -382,6 +382,14 @@ void grpcsharp_slice_buffer_adjust_tail_space() {
fprintf(stderr, "Should never reach here"); fprintf(stderr, "Should never reach here");
abort(); abort();
} }
void grpcsharp_slice_buffer_slice_count() {
fprintf(stderr, "Should never reach here");
abort();
}
void grpcsharp_slice_buffer_slice_peek() {
fprintf(stderr, "Should never reach here");
abort();
}
void grpcsharp_slice_buffer_destroy() { void grpcsharp_slice_buffer_destroy() {
fprintf(stderr, "Should never reach here"); fprintf(stderr, "Should never reach here");
abort(); abort();

@ -90,6 +90,8 @@ native_method_signatures = [
'void grpcsharp_auth_context_release(IntPtr authContext)', 'void grpcsharp_auth_context_release(IntPtr authContext)',
'SliceBufferSafeHandle grpcsharp_slice_buffer_create()', 'SliceBufferSafeHandle grpcsharp_slice_buffer_create()',
'IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace)', 'IntPtr grpcsharp_slice_buffer_adjust_tail_space(SliceBufferSafeHandle sliceBuffer, UIntPtr availableTailSpace, UIntPtr requestedTailSpace)',
'UIntPtr grpcsharp_slice_buffer_slice_count(SliceBufferSafeHandle sliceBuffer)',
'void grpcsharp_slice_buffer_slice_peek(SliceBufferSafeHandle sliceBuffer, UIntPtr index, out UIntPtr sliceLen, out IntPtr sliceDataPtr)',
'void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer)', 'void grpcsharp_slice_buffer_destroy(IntPtr sliceBuffer)',
'Timespec gprsharp_now(ClockType clockType)', 'Timespec gprsharp_now(ClockType clockType)',
'Timespec gprsharp_inf_future(ClockType clockType)', 'Timespec gprsharp_inf_future(ClockType clockType)',

Loading…
Cancel
Save