energy/cef/types-process-message.go

109 lines
2.6 KiB
Go
Raw Normal View History

//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//----------------------------------------
package cef
import (
"github.com/energye/energy/v2/cef/internal/def"
2023-05-31 18:00:34 +08:00
"github.com/energye/energy/v2/common/imports"
"github.com/energye/golcl/lcl/api"
"unsafe"
)
2023-02-26 21:17:28 +08:00
// ProcessMessageRef -> ICefProcessMessage
var ProcessMessageRef processMessage
2023-02-26 21:17:28 +08:00
// processMessage
type processMessage uintptr
2023-03-03 15:26:27 +08:00
// new 创建一个进程消息类型 - internal
//
// 参数: name 消息名
2023-03-03 15:26:27 +08:00
func (*processMessage) new(name string) *ICefProcessMessage {
var result uintptr
imports.Proc(def.CefProcessMessageRef_New).Call(api.PascalStr(name), uintptr(unsafe.Pointer(&result)))
return &ICefProcessMessage{
2023-03-03 15:26:27 +08:00
name: name,
instance: unsafe.Pointer(result),
}
}
2023-03-03 15:26:27 +08:00
// New 创建一个进程消息类型 - export
//
// 参数: name 消息名
func (m *processMessage) New(name string) *ICefProcessMessage {
2023-03-13 17:30:13 +08:00
if isIPCInternalKey(name) {
2023-03-03 15:26:27 +08:00
return nil
}
return m.new(name)
}
2023-03-04 11:58:35 +08:00
func (m *processMessage) UnWrap(data *ICefProcessMessage) *ICefProcessMessage {
var result uintptr
imports.Proc(def.CefProcessMessageRef_UnWrap).Call(data.Instance(), uintptr(unsafe.Pointer(&result)))
2023-03-04 11:58:35 +08:00
data.instance = unsafe.Pointer(result)
return data
}
2023-03-03 15:26:27 +08:00
// Instance 实例
func (m *ICefProcessMessage) Instance() uintptr {
2023-05-31 17:41:14 +08:00
if m == nil {
return 0
}
return uintptr(m.instance)
}
2023-05-31 17:41:14 +08:00
func (m *ICefProcessMessage) Free() {
if m != nil && m.instance != nil {
m.ArgumentList().Free()
m.base.Free(m.Instance())
m.instance = nil
}
}
func (m *ICefProcessMessage) IsValid() bool {
if m == nil || m.instance == nil {
return false
}
r1, _, _ := imports.Proc(def.CefProcessMessage_IsValid).Call(m.Instance())
2023-05-31 17:41:14 +08:00
return api.GoBool(r1)
}
2023-03-03 15:26:27 +08:00
// ArgumentList 参数列表
func (m *ICefProcessMessage) ArgumentList() *ICefListValue {
2023-03-21 13:18:44 +08:00
if m.Name() == "" || !m.IsValid() {
2023-03-03 15:26:27 +08:00
return nil
}
2023-03-01 14:18:39 +08:00
if m.argumentList == nil {
var result uintptr
imports.Proc(def.CefProcessMessage_ArgumentList).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
2023-03-01 14:18:39 +08:00
m.argumentList = &ICefListValue{
instance: unsafe.Pointer(result),
}
}
2023-03-01 14:18:39 +08:00
return m.argumentList
}
func (m *ICefProcessMessage) Copy() *ICefProcessMessage {
var result uintptr
imports.Proc(def.CefProcessMessage_Copy).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
return &ICefProcessMessage{
instance: unsafe.Pointer(result),
}
}
func (m *ICefProcessMessage) Name() string {
2023-03-03 15:26:27 +08:00
if m.name == "" {
r1, _, _ := imports.Proc(def.CefProcessMessage_Name).Call(m.Instance())
2023-03-03 15:26:27 +08:00
m.name = api.GoStr(r1)
}
return m.name
}