2023-03-08 23:34:17 +08:00
|
|
|
//----------------------------------------
|
|
|
|
//
|
|
|
|
// 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 (
|
2023-05-31 18:00:34 +08:00
|
|
|
"github.com/energye/energy/v2/common/imports"
|
2023-03-08 23:34:17 +08:00
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2023-03-09 23:17:55 +08:00
|
|
|
type ICefBaseRefCounted interface {
|
2023-05-31 17:41:14 +08:00
|
|
|
Instance() uintptr
|
|
|
|
IsValid() bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewBaseRefCounted(instance uintptr) *TCefBaseRefCounted {
|
|
|
|
return &TCefBaseRefCounted{instance: unsafe.Pointer(instance)}
|
2023-03-09 23:17:55 +08:00
|
|
|
}
|
|
|
|
|
2023-03-09 19:27:00 +08:00
|
|
|
// Wrap 指针引用包裹
|
2023-03-09 23:17:55 +08:00
|
|
|
func (m *TCefBaseRefCounted) Wrap(data uintptr) unsafe.Pointer {
|
2023-03-08 23:34:17 +08:00
|
|
|
var result uintptr
|
|
|
|
imports.Proc(internale_CefBaseRefCounted_Wrap).Call(data, uintptr(unsafe.Pointer(&result)))
|
|
|
|
return unsafe.Pointer(result)
|
|
|
|
}
|
|
|
|
|
2023-03-09 19:27:00 +08:00
|
|
|
// Free 释放底层指针
|
2023-03-09 23:17:55 +08:00
|
|
|
func (m *TCefBaseRefCounted) Free(data uintptr) {
|
2023-03-08 23:34:17 +08:00
|
|
|
imports.Proc(internale_CefBaseRefCounted_Free).Call(uintptr(unsafe.Pointer(&data)))
|
2023-03-09 16:35:38 +08:00
|
|
|
m.instance = nil
|
2023-03-08 23:34:17 +08:00
|
|
|
}
|
2023-05-31 17:41:14 +08:00
|
|
|
|
|
|
|
// Instance 实例
|
|
|
|
func (m *TCefBaseRefCounted) Instance() uintptr {
|
|
|
|
if m == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
return uintptr(m.instance)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *TCefBaseRefCounted) IsValid() bool {
|
|
|
|
if m == nil || m.instance == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return m.instance != nil
|
|
|
|
}
|