优化&修复 tag -> v17

This commit is contained in:
杨红岩 2023-02-27 20:12:54 +08:00
parent 4d237dbc1a
commit 6b2c675a74
3 changed files with 13 additions and 14 deletions

View File

@ -12,6 +12,7 @@
package cef
import (
"github.com/energye/energy/common"
"github.com/energye/energy/common/imports"
"github.com/energye/golcl/lcl/api"
"unsafe"
@ -73,8 +74,7 @@ func (m *ICefStringMultiMap) GetKey(index uint32) string {
func (m *ICefStringMultiMap) GetValue(index uint32) string {
var result uintptr
imports.Proc(internale_StringMultimap_GetValue).Call(m.Instance(), uintptr(index), uintptr(unsafe.Pointer(&result)))
resultString := (*StringHeader)(unsafe.Pointer(result))
return resultString.GoStr()
return common.GoStr(result)
}
// Append 给key追加值

View File

@ -330,18 +330,6 @@ type Exception struct {
message string
}
type StringHeader struct {
value uintptr
length uintptr
}
func (m *StringHeader) GoStr() string {
if m == nil || m.length <= 0 {
return ""
}
return *(*string)(unsafe.Pointer(m))
}
func (m *Exception) SetMessage(message string) {
m.message = message
}

View File

@ -638,3 +638,14 @@ func GoroutineID() (id uint64) {
}
return id
}
func GoStr(ptr uintptr) string {
if ptr == 0 {
return ""
}
resultString := (*reflect.StringHeader)(unsafe.Pointer(ptr))
if resultString == nil || resultString.Len <= 0 {
return ""
}
return *(*string)(unsafe.Pointer(resultString))
}