Esempio n. 1
0
func NewBlob(content []byte) Blob {
	size := C.size_t(len(content))
	var buf unsafe.Pointer = nil
	if size > 0 {
		buf = unsafe.Pointer(&content[0])
	}
	obj := C.cfish_Blob_new(buf, size)
	return WRAPBlob(unsafe.Pointer(obj))
}
Esempio n. 2
0
func goToBlob(value interface{}, nullable bool) unsafe.Pointer {
	switch v := value.(type) {
	case []byte:
		if v == nil {
			if nullable {
				return nil
			}
		} else {
			size := C.size_t(len(v))
			var buf unsafe.Pointer = nil
			if size > 0 {
				buf = unsafe.Pointer(&v[0])
			}
			return unsafe.Pointer(C.cfish_Blob_new(buf, size))
		}
	case Obj:
		certifyCF(v, C.CFISH_BLOB, nullable)
		return unsafe.Pointer(C.cfish_incref(unsafe.Pointer(v.TOPTR())))
	}
	mess := fmt.Sprintf("Can't convert %T to clownfish.Blob", value)
	panic(NewErr(mess))
}