func extractCefMultiMap(cefMapPointer C.cef_string_multimap_t) map[string][]string { numKeys := C.cef_string_multimap_size(cefMapPointer) goMap := make(map[string][]string) for i := 0; i < int(numKeys); i++ { var key *C.cef_string_utf16_t = C.cef_string_userfree_utf16_alloc() C.cef_string_multimap_key(cefMapPointer, C.int(i), C.cefString16CastToCefString(key)) charKeyUtf8 := C.cefStringToUtf8(C.cefString16CastToCefString(key)) goKey := C.GoString(charKeyUtf8.str) if _, ok := goMap[goKey]; ok { continue } numValsForKey := C.cef_string_multimap_find_count(cefMapPointer, C.cefString16CastToCefString(key)) if numValsForKey >= 0 { goVals := make([]string, numValsForKey) for k := 0; k < int(numValsForKey); k++ { var val *C.cef_string_utf16_t = C.cef_string_userfree_utf16_alloc() C.cef_string_multimap_enumerate(cefMapPointer, C.cefString16CastToCefString(key), C.int(k), C.cefString16CastToCefString(val)) charValUtf8 := C.cefStringToUtf8(C.cefString16CastToCefString(val)) goVals[k] = C.GoString(charValUtf8.str) C.cef_string_userfree_utf8_free(charValUtf8) C.cef_string_userfree_utf16_free(val) } goMap[goKey] = goVals } C.cef_string_userfree_utf8_free(charKeyUtf8) C.cef_string_userfree_utf16_free(key) } return goMap }
func (b CefBrowserT) GetFrameNames() []string { nameList := C.cef_string_list_alloc() C.cef_browser_t_get_frame_names(b.CStruct, nameList) length := int(C.cef_string_list_size(nameList)) goList := make([]string, length) for i := range goList { var cefName *C.cef_string_utf16_t = C.cef_string_userfree_utf16_alloc() didRet := C.cef_string_list_value(nameList, C.int(i), C.cefString16CastToCefString(cefName)) if didRet == C.int(1) { nameUtf8 := C.cefStringToUtf8(C.cefString16CastToCefString(cefName)) goList[i] = C.GoString(nameUtf8.str) C.cef_string_userfree_utf8_free(nameUtf8) } C.cef_string_userfree_utf16_free(cefName) } return goList }