// Helpers which prepare Go-side of cast to eventual C++ Configuration struct. func (server *IceServer) _CGO() C.CGO_IceServer { cServer := new(C.CGO_IceServer) cServer.numUrls = C.int(len(server.Urls)) total := C.int(len(server.Urls)) // TODO: Make this conversion nicer. cUrls := make([](*C.char), total) for i, url := range server.Urls { cUrls[i] = C.CString(url) } cServer.urls = &cUrls[0] cServer.numUrls = total cServer.username = C.CString(server.Username) cServer.credential = C.CString(server.Credential) return *cServer }
// Helpers which prepare Go-side of cast to eventual C++ Configuration struct. func (server *IceServer) _CGO() C.CGO_IceServer { cServer := new(C.CGO_IceServer) // TODO: Make this conversion nicer. total := len(server.Urls) if total > 0 { sizeof := unsafe.Sizeof(uintptr(0)) // FIXME(arlolra): sizeof *void cUrls := unsafe.Pointer(C.malloc(C.size_t(sizeof * uintptr(total)))) ptr := uintptr(cUrls) for _, url := range server.Urls { *(**C.char)(unsafe.Pointer(ptr)) = C.CString(url) ptr += sizeof } cServer.urls = (**C.char)(cUrls) } cServer.numUrls = C.int(total) cServer.username = C.CString(server.Username) cServer.credential = C.CString(server.Credential) return *cServer }