http: add casts because Go doesn't believe in const

This commit is contained in:
Carlos Martín Nieto 2017-04-17 20:19:56 +02:00 committed by Carlos Martín Nieto
parent e2eda97316
commit 1339ad1e71
2 changed files with 8 additions and 4 deletions

View File

@ -335,7 +335,7 @@ func getSmartSubtransportStreamInterface(_s *C.git_smart_subtransport_stream) (S
} }
//export smartSubtransportRead //export smartSubtransportRead
func smartSubtransportRead(s *C.git_smart_subtransport_stream, data unsafe.Pointer, l C.size_t, read *C.size_t) C.int { func smartSubtransportRead(s *C.git_smart_subtransport_stream, data *C.char, l C.size_t, read *C.size_t) C.int {
stream, err := getSmartSubtransportStreamInterface(s) stream, err := getSmartSubtransportStreamInterface(s)
if err != nil { if err != nil {
return setLibgit2Error(err) return setLibgit2Error(err)
@ -345,7 +345,7 @@ func smartSubtransportRead(s *C.git_smart_subtransport_stream, data unsafe.Point
header := (*reflect.SliceHeader)(unsafe.Pointer(&p)) header := (*reflect.SliceHeader)(unsafe.Pointer(&p))
header.Cap = int(l) header.Cap = int(l)
header.Len = int(l) header.Len = int(l)
header.Data = uintptr(data) header.Data = uintptr(unsafe.Pointer(data))
n, err := stream.Read(p) n, err := stream.Read(p)
if err != nil { if err != nil {

View File

@ -198,7 +198,9 @@ int _go_git_transport_smart(git_transport **out, git_remote *owner)
void _go_git_setup_smart_subtransport(managed_smart_subtransport *t, void *ptr) void _go_git_setup_smart_subtransport(managed_smart_subtransport *t, void *ptr)
{ {
t->parent.action = httpAction; typedef int (*transport_action)(git_smart_subtransport_stream **out, git_smart_subtransport *transport, const char *url, git_smart_service_t action);
t->parent.action = (transport_action)httpAction;
t->parent.close = httpClose; t->parent.close = httpClose;
t->parent.free = httpFree; t->parent.free = httpFree;
@ -207,8 +209,10 @@ void _go_git_setup_smart_subtransport(managed_smart_subtransport *t, void *ptr)
void _go_git_setup_smart_subtransport_stream(managed_smart_subtransport_stream *s, void *ptr) void _go_git_setup_smart_subtransport_stream(managed_smart_subtransport_stream *s, void *ptr)
{ {
typedef int (*transport_stream_write)(git_smart_subtransport_stream *stream, const char *buffer, size_t len);
s->parent.read = smartSubtransportRead; s->parent.read = smartSubtransportRead;
s->parent.write = smartSubtransportWrite; s->parent.write = (transport_stream_write)smartSubtransportWrite;
s->parent.free = smartSubtransportFree; s->parent.free = smartSubtransportFree;
s->ptr = ptr; s->ptr = ptr;