Make Blob ctors take void pointers
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/39385c5d Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/39385c5d Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/39385c5d Branch: refs/heads/master Commit: 39385c5d203a92cc33023fe797f3b19bd8937e5c Parents: 9fd7fb5 Author: Nick Wellnhofer <[email protected]> Authored: Mon Jan 11 17:39:08 2016 +0100 Committer: Nick Wellnhofer <[email protected]> Committed: Wed Feb 3 15:24:28 2016 +0100 ---------------------------------------------------------------------- runtime/core/Clownfish/Blob.c | 24 ++++++++++++------------ runtime/core/Clownfish/Blob.cfh | 12 ++++++------ runtime/go/clownfish/clownfish.go | 8 ++++---- 3 files changed, 22 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/39385c5d/runtime/core/Clownfish/Blob.c ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Blob.c b/runtime/core/Clownfish/Blob.c index 3e37e0c..dec4954 100644 --- a/runtime/core/Clownfish/Blob.c +++ b/runtime/core/Clownfish/Blob.c @@ -25,16 +25,16 @@ #include "Clownfish/Util/Memory.h" Blob* -Blob_new(const char *buf, size_t size) { +Blob_new(const void *bytes, size_t size) { Blob *self = (Blob*)Class_Make_Obj(BLOB); - return Blob_init(self, buf, size); + return Blob_init(self, bytes, size); } Blob* -Blob_init(Blob *self, const char *buf, size_t size) { +Blob_init(Blob *self, const void *bytes, size_t size) { char *copy = (char*)MALLOCATE(size); if (size > 0) { - memcpy(copy, buf, size); + memcpy(copy, bytes, size); } self->buf = copy; @@ -45,14 +45,14 @@ Blob_init(Blob *self, const char *buf, size_t size) { } Blob* -Blob_new_steal(char *buf, size_t size) { +Blob_new_steal(void *bytes, size_t size) { Blob *self = (Blob*)Class_Make_Obj(BLOB); - return Blob_init_steal(self, buf, size); + return Blob_init_steal(self, bytes, size); } Blob* -Blob_init_steal(Blob *self, char *buf, size_t size) { - self->buf = buf; +Blob_init_steal(Blob *self, void *bytes, size_t size) { + self->buf = (char*)bytes; self->size = size; self->owns_buf = true; @@ -60,14 +60,14 @@ Blob_init_steal(Blob *self, char *buf, size_t size) { } Blob* -Blob_new_wrap(const char *buf, size_t size) { +Blob_new_wrap(const void *bytes, size_t size) { Blob *self = (Blob*)Class_Make_Obj(BLOB); - return Blob_init_wrap(self, buf, size); + return Blob_init_wrap(self, bytes, size); } Blob* -Blob_init_wrap(Blob *self, const char *buf, size_t size) { - self->buf = buf; +Blob_init_wrap(Blob *self, const void *bytes, size_t size) { + self->buf = (char*)bytes; self->size = size; self->owns_buf = false; http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/39385c5d/runtime/core/Clownfish/Blob.cfh ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Blob.cfh b/runtime/core/Clownfish/Blob.cfh index 9832c5f..fce8379 100644 --- a/runtime/core/Clownfish/Blob.cfh +++ b/runtime/core/Clownfish/Blob.cfh @@ -27,22 +27,22 @@ public final class Clownfish::Blob inherits Clownfish::Obj { bool owns_buf; public inert incremented Blob* - new(const char *buf, size_t size); + new(const void *bytes, size_t size); public inert Blob* - init(Blob *self, const char *buf, size_t size); + init(Blob *self, const void *bytes, size_t size); public inert incremented Blob* - new_steal(char *buf, size_t size); + new_steal(void *bytes, size_t size); public inert Blob* - init_steal(Blob *self, char *buf, size_t size); + init_steal(Blob *self, void *bytes, size_t size); public inert incremented Blob* - new_wrap(const char *buf, size_t size); + new_wrap(const void *bytes, size_t size); public inert Blob* - init_wrap(Blob *self, const char *buf, size_t size); + init_wrap(Blob *self, const void *bytes, size_t size); void* To_Host(Blob *self); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/39385c5d/runtime/go/clownfish/clownfish.go ---------------------------------------------------------------------- diff --git a/runtime/go/clownfish/clownfish.go b/runtime/go/clownfish/clownfish.go index 96bbf35..4a2ed77 100644 --- a/runtime/go/clownfish/clownfish.go +++ b/runtime/go/clownfish/clownfish.go @@ -349,9 +349,9 @@ func goToBlob(value interface{}, nullable bool) unsafe.Pointer { } } else { size := C.size_t(len(v)) - var buf *C.char = nil + var buf unsafe.Pointer = nil if size > 0 { - buf = ((*C.char)(unsafe.Pointer(&v[0]))) + buf = unsafe.Pointer(&v[0]) } return unsafe.Pointer(C.cfish_Blob_new(buf, size)) } @@ -665,9 +665,9 @@ func NewBoolean(val bool) Boolean { func NewBlob(content []byte) Blob { size := C.size_t(len(content)) - var buf *C.char = nil + var buf unsafe.Pointer = nil if size > 0 { - buf = ((*C.char)(unsafe.Pointer(&content[0]))) + buf = unsafe.Pointer(&content[0]) } obj := C.cfish_Blob_new(buf, size) return WRAPBlob(unsafe.Pointer(obj))
