func (c *CGoSystem) ReadData(consumerHandle uint32, flags uint32) (result uint32, buf []byte) { var numBytes C.uint32_t if r := C.MojoReadData(C.MojoHandle(consumerHandle), nil, &numBytes, C.MOJO_READ_DATA_FLAG_QUERY); r != C.MOJO_RESULT_OK { return uint32(r), nil } buf = make([]byte, int(numBytes)) r := C.MojoReadData(C.MojoHandle(consumerHandle), unsafe.Pointer(&buf[0]), &numBytes, C.MojoReadDataFlags(flags)) buf = buf[0:int(numBytes)] return uint32(r), buf }
func (c *CGoSystem) MapBuffer(handle uint32, offset, numBytes uint64, flags uint32) (result uint32, buf []byte) { var bufPtr unsafe.Pointer r := C.MojoMapBuffer(C.MojoHandle(handle), C.uint64_t(offset), C.uint64_t(numBytes), &bufPtr, C.MojoMapBufferFlags(flags)) if r != C.MOJO_RESULT_OK { return uint32(r), nil } return uint32(r), unsafeByteSlice(bufPtr, int(numBytes)) }
func (c *CGoSystem) BeginReadData(consumerHandle uint32, flags uint32) (result uint32, buf []byte) { var buffer unsafe.Pointer var bufferNumBytes C.uint32_t r := C.MojoBeginReadData(C.MojoHandle(consumerHandle), &buffer, &bufferNumBytes, C.MojoReadDataFlags(flags)) if r != C.MOJO_RESULT_OK { return uint32(r), nil } return uint32(r), unsafeByteSlice(buffer, int(bufferNumBytes)) }
func (c *CGoSystem) BeginWriteData(producerHandle uint32, numBytes uint32, flags uint32) (result uint32, buf []byte) { var buffer unsafe.Pointer bufferNumBytes := C.uint32_t(numBytes) r := C.MojoBeginWriteData(C.MojoHandle(producerHandle), &buffer, &bufferNumBytes, C.MojoWriteDataFlags(flags)) if r != C.MOJO_RESULT_OK { return uint32(r), nil } return uint32(r), unsafeByteSlice(buffer, int(bufferNumBytes)) }
func (c *CGoSystem) DuplicateBufferHandle(handle uint32, flags uint32) (uint32, uint32) { var opts *C.struct_MojoDuplicateBufferHandleOptions opts = &C.struct_MojoDuplicateBufferHandleOptions{ C.uint32_t(unsafe.Sizeof(*opts)), C.MojoDuplicateBufferHandleOptionsFlags(flags), } var cDuplicateHandle C.MojoHandle r := C.DuplicateBufferHandle(C.MojoHandle(handle), opts, &cDuplicateHandle) return uint32(r), uint32(cDuplicateHandle) }
func (c *CGoSystem) WriteMessage(handle uint32, bytes []byte, handles []uint32, flags uint32) (result uint32) { var bytesPtr unsafe.Pointer if len(bytes) != 0 { bytesPtr = unsafe.Pointer(&bytes[0]) } var handlesPtr *C.MojoHandle if len(handles) != 0 { handlesPtr = (*C.MojoHandle)(unsafe.Pointer(&handles[0])) } return uint32(C.MojoWriteMessage(C.MojoHandle(handle), bytesPtr, C.uint32_t(len(bytes)), handlesPtr, C.uint32_t(len(handles)), C.MojoWriteMessageFlags(flags))) }
func (c *CGoSystem) ReadMessage(handle uint32, flags uint32) (result uint32, buf []byte, handles []uint32) { var numBytes, numHandles C.uint32_t cHandle := C.MojoHandle(handle) cFlags := C.MojoReadMessageFlags(flags) if r := C.MojoReadMessage(cHandle, nil, &numBytes, nil, &numHandles, cFlags); r != C.MOJO_RESULT_RESOURCE_EXHAUSTED { return uint32(r), nil, nil } var bufPtr unsafe.Pointer if numBytes != 0 { buf = make([]byte, int(numBytes)) bufPtr = unsafe.Pointer(&buf[0]) } var handlesPtr *C.MojoHandle if numHandles != 0 { handles = make([]uint32, int(numHandles)) handlesPtr = (*C.MojoHandle)(unsafe.Pointer(&handles[0])) } r := C.MojoReadMessage(cHandle, bufPtr, &numBytes, handlesPtr, &numHandles, cFlags) return uint32(r), buf, handles }
func (c *CGoSystem) Wait(handle uint32, signals uint32, deadline uint64) (result uint32, satisfiedSignals, satisfiableSignals uint32) { var cState C.struct_MojoHandleSignalsState r := C.MojoWait(C.MojoHandle(handle), C.MojoHandleSignals(signals), C.MojoDeadline(deadline), &cState) return uint32(r), uint32(cState.satisfied_signals), uint32(cState.satisfiable_signals) }
func (c *CGoSystem) Close(handle uint32) (result uint32) { return uint32(C.MojoClose(C.MojoHandle(handle))) }
func (c *CGoSystem) EndReadData(consumerHandle uint32, numBytesRead uint32) (result uint32) { return uint32(C.MojoEndReadData(C.MojoHandle(consumerHandle), C.uint32_t(numBytesRead))) }
func (c *CGoSystem) EndWriteData(producerHandle uint32, numBytesWritten uint32) (result uint32) { return uint32(C.MojoEndWriteData(C.MojoHandle(producerHandle), C.uint32_t(numBytesWritten))) }
func (c *CGoSystem) WriteData(producerHandle uint32, buf []byte, flags uint32) (result uint32, bytesWritten uint32) { numBytes := C.uint32_t(len(buf)) r := C.MojoWriteData(C.MojoHandle(producerHandle), unsafe.Pointer(&buf[0]), &numBytes, C.MojoWriteDataFlags(flags)) return uint32(r), uint32(numBytes) }