提交 a068b7ab 编写于 作者: yanghye's avatar yanghye

Optimize code usage

上级 28712f1c
......@@ -16,6 +16,7 @@ import (
"github.com/energye/energy/logger"
"github.com/energye/golcl/energy/inits"
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/api"
"github.com/energye/golcl/pkgs/macapp"
)
......@@ -47,7 +48,7 @@ func GlobalCEFInit(libs *embed.FS, resources *embed.FS) {
//IPC通道选择初始化, 在不支持unix的系统中将选择net socket
ipc.IPCChannelChooseInit()
//macos的命令行设置
setMacOSXCommandLine(GoStrToDStr(Args.CommandLine()))
setMacOSXCommandLine(api.PascalStr(Args.CommandLine()))
applicationQueueAsyncCallInit()
//对于go绑定到v8引擎js的事件处理函数
cefV8WindowBindFuncEventsInit()
......
......@@ -69,31 +69,6 @@ func InterfaceToString(value interface{}) string {
return fmt.Sprintf("%v", value)
}
func copyStr(src uintptr, strLen int) string {
if strLen == 0 {
return ""
}
str := make([]uint8, strLen)
for i := 0; i < strLen; i++ {
str[i] = *(*uint8)(unsafe.Pointer(src + uintptr(i)))
}
return string(str)
}
//golcl > stdstr.go > DStrToGoStr
//Lazarus的string转换为Go的string
//参数1 要转换字符串的地址,参数2 已知字符串长度
func DStrToGoStr(ustr uintptr, len int) string {
if len == 0 {
return ""
}
return copyStr(ustr, len)
}
func GoStrToDStr(s string) uintptr {
return api.PascalStr(s)
}
// 获取参数指针
func GetParamOf(index int, ptr uintptr) uintptr {
return *(*uintptr)(unsafe.Pointer(ptr + uintptr(index)*unsafe.Sizeof(ptr)))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册