2023-02-25 19:13:07 +08:00
|
|
|
|
//----------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Copyright © yanghy. All Rights Reserved.
|
|
|
|
|
//
|
|
|
|
|
// Licensed under Apache License Version 2.0, January 2004
|
|
|
|
|
//
|
|
|
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
|
|
// CEF v8 value V8所有类型
|
2023-03-14 19:00:36 +08:00
|
|
|
|
//
|
|
|
|
|
// ICefV8Value 创建和使用一搬在 v8context 上下文中使用
|
2023-02-23 14:34:23 +08:00
|
|
|
|
package cef
|
|
|
|
|
|
|
|
|
|
import (
|
2023-03-24 09:24:03 +08:00
|
|
|
|
"github.com/energye/energy/cef/ipc"
|
2023-02-23 14:34:23 +08:00
|
|
|
|
"github.com/energye/energy/common"
|
|
|
|
|
"github.com/energye/energy/common/imports"
|
|
|
|
|
"github.com/energye/energy/consts"
|
2023-03-03 10:00:29 +08:00
|
|
|
|
"github.com/energye/golcl/lcl"
|
2023-02-23 14:34:23 +08:00
|
|
|
|
"github.com/energye/golcl/lcl/api"
|
|
|
|
|
"time"
|
|
|
|
|
"unsafe"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) Instance() uintptr {
|
|
|
|
|
if m == nil {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
return uintptr(m.instance)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) IsValid() bool {
|
2023-02-24 10:12:55 +08:00
|
|
|
|
if m == nil || m.instance == nil {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_IsValid).Call(m.Instance())
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) IsUndefined() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-02 23:47:20 +08:00
|
|
|
|
if m.valueType == consts.V8vtUndefined {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
if m.valueType == consts.V8vtInvalid {
|
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_IsUndefined).Call(m.Instance())
|
|
|
|
|
if api.GoBool(r1) {
|
|
|
|
|
m.valueType = consts.V8vtUndefined
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) IsNull() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-02 23:47:20 +08:00
|
|
|
|
if m.valueType == consts.V8vtNull {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
if m.valueType == consts.V8vtInvalid {
|
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_IsNull).Call(m.Instance())
|
|
|
|
|
if api.GoBool(r1) {
|
|
|
|
|
m.valueType = consts.V8vtNull
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) IsBool() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-02 23:47:20 +08:00
|
|
|
|
if m.valueType == consts.V8vtBool {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
if m.valueType == consts.V8vtInvalid {
|
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_IsBool).Call(m.Instance())
|
|
|
|
|
if api.GoBool(r1) {
|
|
|
|
|
m.valueType = consts.V8vtBool
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) IsInt() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-02 23:47:20 +08:00
|
|
|
|
if m.valueType == consts.V8vtInt {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
if m.valueType == consts.V8vtInvalid {
|
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_IsInt).Call(m.Instance())
|
|
|
|
|
if api.GoBool(r1) {
|
|
|
|
|
m.valueType = consts.V8vtInt
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) IsUInt() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-02 23:47:20 +08:00
|
|
|
|
if m.valueType == consts.V8vtUInt {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
if m.valueType == consts.V8vtInvalid {
|
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_IsUInt).Call(m.Instance())
|
|
|
|
|
if api.GoBool(r1) {
|
|
|
|
|
m.valueType = consts.V8vtUInt
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) IsDouble() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-02 23:47:20 +08:00
|
|
|
|
if m.valueType == consts.V8vtDouble {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
if m.valueType == consts.V8vtInvalid {
|
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_IsDouble).Call(m.Instance())
|
|
|
|
|
if api.GoBool(r1) {
|
|
|
|
|
m.valueType = consts.V8vtDouble
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) IsDate() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-02 23:47:20 +08:00
|
|
|
|
if m.valueType == consts.V8vtDate {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
if m.valueType == consts.V8vtInvalid {
|
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_IsDate).Call(m.Instance())
|
|
|
|
|
if api.GoBool(r1) {
|
|
|
|
|
m.valueType = consts.V8vtDate
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) IsString() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-02 23:47:20 +08:00
|
|
|
|
if m.valueType == consts.V8vtString {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
if m.valueType == consts.V8vtInvalid {
|
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_IsString).Call(m.Instance())
|
|
|
|
|
if api.GoBool(r1) {
|
|
|
|
|
m.valueType = consts.V8vtString
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) IsObject() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-02 23:47:20 +08:00
|
|
|
|
if m.valueType == consts.V8vtObject {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
if m.valueType == consts.V8vtInvalid {
|
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_IsObject).Call(m.Instance())
|
|
|
|
|
if api.GoBool(r1) {
|
|
|
|
|
m.valueType = consts.V8vtObject
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) IsArray() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-02 23:47:20 +08:00
|
|
|
|
if m.valueType == consts.V8vtArray {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
if m.valueType == consts.V8vtInvalid {
|
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_IsArray).Call(m.Instance())
|
|
|
|
|
if api.GoBool(r1) {
|
|
|
|
|
m.valueType = consts.V8vtArray
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) IsArrayBuffer() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-02 23:47:20 +08:00
|
|
|
|
if m.valueType == consts.V8vtArrayBuffer {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
if m.valueType == consts.V8vtInvalid {
|
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_IsArrayBuffer).Call(m.Instance())
|
|
|
|
|
if api.GoBool(r1) {
|
|
|
|
|
m.valueType = consts.V8vtArrayBuffer
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) IsFunction() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-02 23:47:20 +08:00
|
|
|
|
if m.valueType == consts.V8vtFunction {
|
2023-03-03 23:41:55 +08:00
|
|
|
|
//return true
|
2023-03-02 23:47:20 +08:00
|
|
|
|
}
|
2023-03-03 23:41:55 +08:00
|
|
|
|
//if m.valueType == consts.V8vtInvalid {
|
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_IsFunction).Call(m.Instance())
|
|
|
|
|
if api.GoBool(r1) {
|
|
|
|
|
m.valueType = consts.V8vtFunction
|
|
|
|
|
return true
|
2023-03-02 23:47:20 +08:00
|
|
|
|
}
|
2023-03-03 23:41:55 +08:00
|
|
|
|
//}
|
2023-03-02 23:47:20 +08:00
|
|
|
|
return false
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) IsPromise() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-02 23:47:20 +08:00
|
|
|
|
if m.valueType == consts.V8vtPromise {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
if m.valueType == consts.V8vtInvalid {
|
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_IsPromise).Call(m.Instance())
|
|
|
|
|
if api.GoBool(r1) {
|
|
|
|
|
m.valueType = consts.V8vtPromise
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) IsSame() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_IsSame).Call(m.Instance())
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) GetBoolValue() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_GetBoolValue).Call(m.Instance())
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) GetIntValue() int32 {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_GetIntValue).Call(m.Instance())
|
|
|
|
|
return int32(r1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) GetUIntValue() uint32 {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2023-03-15 08:58:39 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_GetUIntValue).Call(m.Instance())
|
2023-02-23 14:34:23 +08:00
|
|
|
|
return uint32(r1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) GetDoubleValue() (result float64) {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return 0.0
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
imports.Proc(internale_CefV8Value_GetDoubleValue).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) GetDateValue() time.Time {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return time.Time{}
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
var result float64
|
|
|
|
|
imports.Proc(internale_CefV8Value_GetDateValue).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return common.DDateTimeToGoDateTime(result)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) GetStringValue() string {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_GetStringValue).Call(m.Instance())
|
|
|
|
|
return api.GoStr(r1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) IsUserCreated() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_IsUserCreated).Call(m.Instance())
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//func (m *ICefV8Value) HasException() bool {
|
|
|
|
|
// r1, _, _ := imports.Proc(internale_CefV8Value_HasException).Call(m.Instance())
|
|
|
|
|
// return api.GoBool(r1)
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//func (m *ICefV8Value) GetException() {
|
|
|
|
|
//
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) ClearException() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_ClearException).Call(m.Instance())
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) WillRethrowExceptions() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_WillRethrowExceptions).Call(m.Instance())
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) SetRethrowExceptions(reThrow bool) bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_SetRethrowExceptions).Call(m.Instance(), api.PascalBool(reThrow))
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) HasValueByKey(key string) bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_HasValueByKey).Call(m.Instance(), api.PascalStr(key))
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) HasValueByIndex(index int32) bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_HasValueByIndex).Call(m.Instance(), uintptr(index))
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 18:47:39 +08:00
|
|
|
|
// deleteValueByKey internal
|
|
|
|
|
func (m *ICefV8Value) deleteValueByKey(key string) bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-16 21:19:27 +08:00
|
|
|
|
if m.valueByKeys != nil {
|
|
|
|
|
if v, ok := m.valueByKeys[key]; ok {
|
|
|
|
|
v.Free()
|
|
|
|
|
delete(m.valueByKeys, key)
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_DeleteValueByKey).Call(m.Instance(), api.PascalStr(key))
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 18:47:39 +08:00
|
|
|
|
// DeleteValueByKey export
|
|
|
|
|
func (m *ICefV8Value) DeleteValueByKey(key string) bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-13 17:30:13 +08:00
|
|
|
|
if isIPCInternalKey(key) {
|
2023-03-02 18:47:39 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
return m.deleteValueByKey(key)
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-08 23:32:52 +08:00
|
|
|
|
func (m *ICefV8Value) DeleteValueByIndex(index int) bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-16 21:19:27 +08:00
|
|
|
|
if m.valueByIndex != nil {
|
|
|
|
|
if v := m.valueByIndex[index]; v != nil {
|
|
|
|
|
v.Free()
|
|
|
|
|
m.valueByIndex[index] = nil
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-08 23:32:52 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_DeleteValueByIndex).Call(m.Instance(), uintptr(int32(index)))
|
2023-02-23 14:34:23 +08:00
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 18:47:39 +08:00
|
|
|
|
// getValueByKey internal
|
|
|
|
|
func (m *ICefV8Value) getValueByKey(key string) *ICefV8Value {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-03-03 11:43:19 +08:00
|
|
|
|
if !m.IsObject() {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-03-16 21:19:27 +08:00
|
|
|
|
if m.valueByKeys == nil {
|
|
|
|
|
m.valueByKeys = make(map[string]*ICefV8Value)
|
|
|
|
|
}
|
|
|
|
|
if v, ok := m.valueByKeys[key]; ok {
|
|
|
|
|
v.Free()
|
|
|
|
|
}
|
2023-03-09 16:35:38 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
imports.Proc(internale_CefV8Value_GetValueByKey).Call(m.Instance(), api.PascalStr(key), uintptr(unsafe.Pointer(&result)))
|
2023-03-16 21:19:27 +08:00
|
|
|
|
v := &ICefV8Value{
|
2023-03-09 16:35:38 +08:00
|
|
|
|
instance: unsafe.Pointer(result),
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
2023-03-16 21:19:27 +08:00
|
|
|
|
m.valueByKeys[key] = v
|
|
|
|
|
return v
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 18:47:39 +08:00
|
|
|
|
// GetValueByKey export
|
|
|
|
|
func (m *ICefV8Value) GetValueByKey(key string) *ICefV8Value {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-03-22 13:22:31 +08:00
|
|
|
|
if key == internalIPC {
|
2023-03-02 18:47:39 +08:00
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return m.getValueByKey(key)
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 23:47:20 +08:00
|
|
|
|
// GetValueByIndex 当前是数组时,通过下标取值V8Value
|
|
|
|
|
func (m *ICefV8Value) GetValueByIndex(index int) *ICefV8Value {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-03-02 23:47:20 +08:00
|
|
|
|
if !m.IsArray() {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-03-16 21:19:27 +08:00
|
|
|
|
if m.valueByIndex == nil {
|
|
|
|
|
m.valueByIndex = make([]*ICefV8Value, m.GetArrayLength())
|
|
|
|
|
}
|
|
|
|
|
if v := m.valueByIndex[index]; v != nil {
|
|
|
|
|
v.Free()
|
|
|
|
|
}
|
2023-03-09 16:35:38 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
imports.Proc(internale_CefV8Value_GetValueByIndex).Call(m.Instance(), uintptr(int32(index)), uintptr(unsafe.Pointer(&result)))
|
2023-03-16 21:19:27 +08:00
|
|
|
|
v := &ICefV8Value{
|
2023-03-09 16:35:38 +08:00
|
|
|
|
instance: unsafe.Pointer(result),
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
2023-03-16 21:19:27 +08:00
|
|
|
|
m.valueByIndex[index] = v
|
|
|
|
|
return v
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 18:47:39 +08:00
|
|
|
|
// setValueByKey internal
|
|
|
|
|
func (m *ICefV8Value) setValueByKey(key string, value *ICefV8Value, attribute consts.TCefV8PropertyAttributes) bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-13 10:50:45 +08:00
|
|
|
|
if m.valueByKeys != nil {
|
|
|
|
|
if v, ok := m.valueByKeys[key]; ok {
|
2023-03-16 21:19:27 +08:00
|
|
|
|
if v != value {
|
|
|
|
|
v.Free()
|
|
|
|
|
}
|
2023-03-13 10:50:45 +08:00
|
|
|
|
}
|
|
|
|
|
m.valueByKeys[key] = value
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_SetValueByKey).Call(m.Instance(), api.PascalStr(key), value.Instance(), attribute.ToPtr())
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 18:47:39 +08:00
|
|
|
|
// SetValueByKey export
|
|
|
|
|
func (m *ICefV8Value) SetValueByKey(key string, value *ICefV8Value, attribute consts.TCefV8PropertyAttributes) bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-13 17:30:13 +08:00
|
|
|
|
if isIPCInternalKey(key) {
|
2023-03-02 18:47:39 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
return m.setValueByKey(key, value, attribute)
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-23 14:34:23 +08:00
|
|
|
|
func (m *ICefV8Value) SetValueByIndex(index int32, value *ICefV8Value) bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-13 10:50:45 +08:00
|
|
|
|
if m.valueByIndex != nil {
|
2023-03-16 21:19:27 +08:00
|
|
|
|
if v := m.valueByIndex[index]; v != nil {
|
|
|
|
|
if v != value {
|
|
|
|
|
v.Free()
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-15 17:06:01 +08:00
|
|
|
|
m.valueByIndex[index] = value
|
2023-03-13 10:50:45 +08:00
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_SetValueByIndex).Call(m.Instance(), uintptr(index), value.Instance())
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 18:47:39 +08:00
|
|
|
|
// SetValueByAccessor internal
|
|
|
|
|
func (m *ICefV8Value) setValueByAccessor(key string, settings consts.TCefV8AccessControls, attribute consts.TCefV8PropertyAttributes) bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_SetValueByAccessor).Call(m.Instance(), api.PascalStr(key), settings.ToPtr(), attribute.ToPtr())
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 18:47:39 +08:00
|
|
|
|
// SetValueByAccessor export
|
|
|
|
|
func (m *ICefV8Value) SetValueByAccessor(key string, settings consts.TCefV8AccessControls, attribute consts.TCefV8PropertyAttributes) bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-03-13 17:30:13 +08:00
|
|
|
|
if isIPCInternalKey(key) {
|
2023-03-02 18:47:39 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
return m.setValueByAccessor(key, settings, attribute)
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 10:00:29 +08:00
|
|
|
|
func (m *ICefV8Value) GetKeys() *ICefV8ValueKeys {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-03-03 10:00:29 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_GetKeys).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return &ICefV8ValueKeys{keys: lcl.AsStrings(result), count: int(int32(r1))}
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
|
2023-03-04 11:19:45 +08:00
|
|
|
|
func (m *ICefV8Value) GetIKeys() ipc.IV8ValueKeys {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-03-04 11:19:45 +08:00
|
|
|
|
return m.GetKeys()
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-23 14:34:23 +08:00
|
|
|
|
func (m *ICefV8Value) SetUserData(data *ICefV8Value) bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_SetUserData).Call(m.Instance(), data.Instance())
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) GetUserData() *ICefV8Value {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
imports.Proc(internale_CefV8Value_GetUserData).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return &ICefV8Value{
|
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) GetExternallyAllocatedMemory() int32 {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_GetExternallyAllocatedMemory).Call(m.Instance())
|
|
|
|
|
return int32(r1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) AdjustExternallyAllocatedMemory(changeInBytes int32) int32 {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_AdjustExternallyAllocatedMemory).Call(m.Instance(), uintptr(changeInBytes))
|
|
|
|
|
return int32(r1)
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 23:47:20 +08:00
|
|
|
|
func (m *ICefV8Value) GetArrayLength() int {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_GetArrayLength).Call(m.Instance())
|
2023-03-02 23:47:20 +08:00
|
|
|
|
return int(int32(r1))
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-07 10:55:28 +08:00
|
|
|
|
func (m *ICefV8Value) GetArrayBufferReleaseCallback() *ICefV8ArrayBufferReleaseCallback {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-03-07 10:55:28 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
imports.Proc(internale_CefV8Value_GetArrayBufferReleaseCallback).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return &ICefV8ArrayBufferReleaseCallback{
|
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) NeuterArrayBuffer() bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_NeuterArrayBuffer).Call(m.Instance())
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) GetFunctionName() string {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_GetFunctionName).Call(m.Instance())
|
|
|
|
|
return api.GoStr(r1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) GetFunctionHandler() *ICefV8Handler {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
var result uintptr
|
2023-02-23 23:26:12 +08:00
|
|
|
|
imports.Proc(internale_CefV8Value_GetFunctionHandler).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
|
2023-02-23 14:34:23 +08:00
|
|
|
|
return &ICefV8Handler{
|
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-04 11:19:45 +08:00
|
|
|
|
func (m *ICefV8Value) ExecuteFunction(obj *ICefV8Value, arguments *TCefV8ValueArray) *ICefV8Value {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
var result uintptr
|
2023-03-18 00:19:20 +08:00
|
|
|
|
var argumentsPtr = arguments.Instance()
|
2023-03-21 13:20:02 +08:00
|
|
|
|
if arguments.Size() > 0 && arguments.argumentsCollect != nil {
|
2023-03-06 16:54:14 +08:00
|
|
|
|
var args = make([]uintptr, arguments.Size(), arguments.Size())
|
|
|
|
|
for i, a := range arguments.argumentsCollect {
|
|
|
|
|
args[i] = a.Instance()
|
|
|
|
|
}
|
2023-03-18 00:19:20 +08:00
|
|
|
|
argumentsPtr = uintptr(unsafe.Pointer(&args[0]))
|
2023-03-04 14:40:22 +08:00
|
|
|
|
}
|
2023-03-21 13:20:02 +08:00
|
|
|
|
imports.Proc(internale_CefV8Value_ExecuteFunction).Call(m.Instance(), obj.Instance(), argumentsPtr, uintptr(int32(arguments.Size())), uintptr(unsafe.Pointer(&result)))
|
2023-02-23 14:34:23 +08:00
|
|
|
|
return &ICefV8Value{
|
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-04 11:19:45 +08:00
|
|
|
|
func (m *ICefV8Value) ExecuteFunctionWithContext(v8Context *ICefV8Context, obj *ICefV8Value, arguments *TCefV8ValueArray) *ICefV8Value {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
var result uintptr
|
2023-03-18 00:19:20 +08:00
|
|
|
|
var argumentsPtr = arguments.Instance()
|
|
|
|
|
if arguments.Size() > 0 && arguments.argumentsCollect != nil {
|
2023-03-06 16:54:14 +08:00
|
|
|
|
var args = make([]uintptr, arguments.Size(), arguments.Size())
|
2023-03-18 00:19:20 +08:00
|
|
|
|
for i, v := range arguments.argumentsCollect {
|
|
|
|
|
args[i] = v.Instance()
|
2023-03-06 16:54:14 +08:00
|
|
|
|
}
|
2023-03-18 00:19:20 +08:00
|
|
|
|
argumentsPtr = uintptr(unsafe.Pointer(&args[0]))
|
2023-03-04 14:40:22 +08:00
|
|
|
|
}
|
2023-03-21 13:18:44 +08:00
|
|
|
|
//argumentsPtr = uintptr(unsafe.Pointer(&argumentsPtr))
|
|
|
|
|
imports.Proc(internale_CefV8Value_ExecuteFunctionWithContext).Call(m.Instance(), v8Context.Instance(), obj.Instance(), argumentsPtr, uintptr(int32(arguments.Size())), uintptr(unsafe.Pointer(&result)))
|
2023-03-18 00:19:20 +08:00
|
|
|
|
return &ICefV8Value{
|
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) ExecuteFunctionWithContextForArgsBytes(v8Context *ICefV8Context, obj *ICefV8Value, arguments []byte) *ICefV8Value {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-03-18 00:19:20 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
var argumentsPtr = uintptr(unsafe.Pointer(&arguments[0]))
|
|
|
|
|
var argumentsLength = uintptr(uint32(len(arguments)))
|
|
|
|
|
imports.Proc(internale_CefV8Value_ExecuteFunctionWithContextForArgsBytes).Call(m.Instance(), v8Context.Instance(), obj.Instance(), argumentsPtr, argumentsLength, uintptr(unsafe.Pointer(&result)))
|
2023-02-23 14:34:23 +08:00
|
|
|
|
return &ICefV8Value{
|
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) ResolvePromise(arg *ICefV8Value) bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_ResolvePromise).Call(m.Instance(), arg.Instance())
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8Value) RejectPromise(errorMsg string) bool {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
r1, _, _ := imports.Proc(internale_CefV8Value_RejectPromise).Call(m.Instance(), api.PascalStr(errorMsg))
|
|
|
|
|
return api.GoBool(r1)
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-16 14:04:39 +08:00
|
|
|
|
func (m *ICefV8Value) SetCanNotFree(v bool) {
|
2023-03-23 10:42:02 +08:00
|
|
|
|
if !m.IsValid() {
|
|
|
|
|
return
|
|
|
|
|
}
|
2023-03-16 14:04:39 +08:00
|
|
|
|
m.cantFree = v
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-23 22:19:04 +08:00
|
|
|
|
func (m *ICefV8Value) Free() {
|
2023-03-21 19:34:40 +08:00
|
|
|
|
if m != nil && m.instance != nil {
|
2023-03-13 10:50:45 +08:00
|
|
|
|
if m.valueByIndex != nil {
|
|
|
|
|
for _, v := range m.valueByIndex {
|
2023-03-16 14:04:39 +08:00
|
|
|
|
if v != nil {
|
2023-03-13 10:50:45 +08:00
|
|
|
|
v.Free()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m.valueByIndex = nil
|
|
|
|
|
}
|
|
|
|
|
if m.valueByKeys != nil {
|
|
|
|
|
for _, v := range m.valueByKeys {
|
2023-03-16 14:04:39 +08:00
|
|
|
|
if v != nil {
|
2023-03-13 10:50:45 +08:00
|
|
|
|
v.Free()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m.valueByKeys = nil
|
|
|
|
|
}
|
2023-03-16 14:04:39 +08:00
|
|
|
|
if !m.cantFree {
|
2023-03-21 13:18:44 +08:00
|
|
|
|
//var ptr = m.Instance()
|
|
|
|
|
//imports.Proc(internale_CefV8Value_Free).Call(uintptr(unsafe.Pointer(&ptr)))
|
|
|
|
|
m.base.Free(m.Instance())
|
2023-03-16 14:04:39 +08:00
|
|
|
|
m.instance = nil
|
|
|
|
|
}
|
2023-03-12 21:02:35 +08:00
|
|
|
|
}
|
2023-02-23 22:19:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 19:13:07 +08:00
|
|
|
|
// ResultV8Value 返回 ICefV8Value 的替代结构
|
2023-02-23 22:19:04 +08:00
|
|
|
|
type ResultV8Value struct {
|
|
|
|
|
v8value *ICefV8Value
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 19:13:07 +08:00
|
|
|
|
// SetResult 设置 ICefV8Value 返回值
|
2023-02-23 22:19:04 +08:00
|
|
|
|
func (m *ResultV8Value) SetResult(v8value *ICefV8Value) {
|
|
|
|
|
m.v8value = v8value
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-04 11:19:45 +08:00
|
|
|
|
// V8ValueArrayRef -> TCefV8ValueArray
|
|
|
|
|
var V8ValueArrayRef v8ValueArray
|
|
|
|
|
|
|
|
|
|
// v8ValueArray
|
|
|
|
|
type v8ValueArray uintptr
|
|
|
|
|
|
|
|
|
|
func (*v8ValueArray) New() *TCefV8ValueArray {
|
|
|
|
|
return &TCefV8ValueArray{
|
|
|
|
|
argumentsCollect: []*ICefV8Value{},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *TCefV8ValueArray) Instance() uintptr {
|
2023-03-07 18:04:02 +08:00
|
|
|
|
if m == nil {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2023-03-04 11:19:45 +08:00
|
|
|
|
return uintptr(m.instance)
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 19:13:07 +08:00
|
|
|
|
// Get 根据下标获取 ICefV8Value
|
2023-02-23 23:05:26 +08:00
|
|
|
|
func (m *TCefV8ValueArray) Get(index int) *ICefV8Value {
|
2023-03-07 18:04:02 +08:00
|
|
|
|
if m == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2023-02-23 23:05:26 +08:00
|
|
|
|
if index < m.argumentsLength {
|
2023-03-02 22:20:42 +08:00
|
|
|
|
value := m.argumentsCollect[index]
|
|
|
|
|
if value == nil {
|
|
|
|
|
value = &ICefV8Value{instance: unsafe.Pointer(common.GetParamOf(index, m.arguments))}
|
|
|
|
|
m.argumentsCollect[index] = value
|
|
|
|
|
}
|
|
|
|
|
return value
|
2023-02-23 23:05:26 +08:00
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 19:13:07 +08:00
|
|
|
|
// Size 返回 ICefV8Value 数组长度
|
2023-02-23 23:05:26 +08:00
|
|
|
|
func (m *TCefV8ValueArray) Size() int {
|
2023-03-07 18:04:02 +08:00
|
|
|
|
if m == nil {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
2023-02-23 23:05:26 +08:00
|
|
|
|
return m.argumentsLength
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 22:20:42 +08:00
|
|
|
|
func (m *TCefV8ValueArray) Free() {
|
2023-03-07 18:04:02 +08:00
|
|
|
|
if m == nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
2023-03-16 14:04:39 +08:00
|
|
|
|
if m.argumentsCollect != nil {
|
|
|
|
|
for _, v := range m.argumentsCollect {
|
2023-03-18 00:19:20 +08:00
|
|
|
|
if v != nil {
|
2023-03-16 14:04:39 +08:00
|
|
|
|
v.Free()
|
2023-03-09 16:35:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-12 21:02:35 +08:00
|
|
|
|
m.argumentsCollect = nil
|
2023-03-09 16:35:38 +08:00
|
|
|
|
}
|
2023-03-16 14:04:39 +08:00
|
|
|
|
m.instance = nil
|
|
|
|
|
m.arguments = 0
|
|
|
|
|
m.argumentsLength = 0
|
2023-03-02 22:20:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-04 11:19:45 +08:00
|
|
|
|
func (m *TCefV8ValueArray) Add(value *ICefV8Value) {
|
|
|
|
|
m.argumentsCollect = append(m.argumentsCollect, value)
|
|
|
|
|
m.argumentsLength++
|
2023-03-04 14:40:22 +08:00
|
|
|
|
m.instance = unsafe.Pointer(m.argumentsCollect[0].Instance())
|
2023-03-04 11:19:45 +08:00
|
|
|
|
m.arguments = uintptr(m.instance)
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-06 12:26:25 +08:00
|
|
|
|
func (m *TCefV8ValueArray) Set(value []*ICefV8Value) {
|
2023-03-09 16:35:38 +08:00
|
|
|
|
if m.argumentsCollect != nil {
|
|
|
|
|
for _, v := range m.argumentsCollect {
|
|
|
|
|
if v != nil && v.instance != nil {
|
|
|
|
|
v.Free()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-06 12:26:25 +08:00
|
|
|
|
m.argumentsCollect = value
|
|
|
|
|
m.argumentsLength = len(value)
|
|
|
|
|
m.instance = unsafe.Pointer(m.argumentsCollect[0].Instance())
|
|
|
|
|
m.arguments = uintptr(m.instance)
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 12:01:31 +08:00
|
|
|
|
// V8ValueRef -> ICefV8Value
|
|
|
|
|
var V8ValueRef cefV8Value
|
2023-02-23 14:34:23 +08:00
|
|
|
|
|
2023-02-25 12:01:31 +08:00
|
|
|
|
// cefV8Value
|
|
|
|
|
type cefV8Value uintptr
|
2023-02-23 14:34:23 +08:00
|
|
|
|
|
2023-02-25 12:01:31 +08:00
|
|
|
|
func (*cefV8Value) NewUndefined() *ICefV8Value {
|
2023-02-23 14:34:23 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
imports.Proc(internale_CefV8ValueRef_NewUndefined).Call(uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return &ICefV8Value{
|
2023-03-02 23:47:20 +08:00
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
valueType: consts.V8vtUndefined,
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 12:01:31 +08:00
|
|
|
|
func (*cefV8Value) NewNull() *ICefV8Value {
|
2023-02-23 14:34:23 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
imports.Proc(internale_CefV8ValueRef_NewNull).Call(uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return &ICefV8Value{
|
2023-03-02 23:47:20 +08:00
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
valueType: consts.V8vtNull,
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 12:01:31 +08:00
|
|
|
|
func (*cefV8Value) NewBool(value bool) *ICefV8Value {
|
2023-02-23 14:34:23 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
imports.Proc(internale_CefV8ValueRef_NewBool).Call(api.PascalBool(value), uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return &ICefV8Value{
|
2023-03-02 23:47:20 +08:00
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
valueType: consts.V8vtBool,
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-25 12:01:31 +08:00
|
|
|
|
func (*cefV8Value) NewInt(value int32) *ICefV8Value {
|
2023-02-23 14:34:23 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
imports.Proc(internale_CefV8ValueRef_NewInt).Call(uintptr(value), uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return &ICefV8Value{
|
2023-03-02 23:47:20 +08:00
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
valueType: consts.V8vtInt,
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 12:01:31 +08:00
|
|
|
|
func (*cefV8Value) NewUInt(value uint32) *ICefV8Value {
|
2023-02-23 14:34:23 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
imports.Proc(internale_CefV8ValueRef_NewUInt).Call(uintptr(value), uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return &ICefV8Value{
|
2023-03-02 23:47:20 +08:00
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
valueType: consts.V8vtUInt,
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 12:01:31 +08:00
|
|
|
|
func (*cefV8Value) NewDouble(value float64) *ICefV8Value {
|
2023-02-23 14:34:23 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
imports.Proc(internale_CefV8ValueRef_NewDouble).Call(uintptr(unsafe.Pointer(&value)), uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return &ICefV8Value{
|
2023-03-02 23:47:20 +08:00
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
valueType: consts.V8vtDouble,
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 12:01:31 +08:00
|
|
|
|
func (*cefV8Value) NewDate(value time.Time) *ICefV8Value {
|
2023-02-23 14:34:23 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
val := common.GoDateTimeToDDateTime(value)
|
|
|
|
|
imports.Proc(internale_CefV8ValueRef_NewDate).Call(uintptr(unsafe.Pointer(&val)), uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return &ICefV8Value{
|
2023-03-02 23:47:20 +08:00
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
valueType: consts.V8vtDate,
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 12:01:31 +08:00
|
|
|
|
func (*cefV8Value) NewString(value string) *ICefV8Value {
|
2023-02-23 14:34:23 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
imports.Proc(internale_CefV8ValueRef_NewString).Call(api.PascalStr(value), uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return &ICefV8Value{
|
2023-03-02 23:47:20 +08:00
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
valueType: consts.V8vtString,
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 20:09:57 +08:00
|
|
|
|
//func (*cefV8Value) NewObject(accessor *ICefV8Accessor, interceptor *ICefV8Interceptor) *ICefV8Value {
|
|
|
|
|
func (*cefV8Value) NewObject(accessor *ICefV8Accessor) *ICefV8Value {
|
2023-02-23 14:34:23 +08:00
|
|
|
|
var result uintptr
|
2023-03-21 19:34:40 +08:00
|
|
|
|
if accessor == nil || accessor.instance == nil {
|
|
|
|
|
imports.Proc(internale_CefV8ValueRef_NewObject).Call(uintptr(0), uintptr(0), uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
} else {
|
|
|
|
|
imports.Proc(internale_CefV8ValueRef_NewObject).Call(accessor.Instance(), uintptr(0), uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
return &ICefV8Value{
|
2023-03-13 10:50:45 +08:00
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
valueType: consts.V8vtObject,
|
|
|
|
|
valueByKeys: make(map[string]*ICefV8Value),
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 12:01:31 +08:00
|
|
|
|
func (*cefV8Value) NewArray(len int32) *ICefV8Value {
|
2023-02-24 11:37:39 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
imports.Proc(internale_CefV8ValueRef_NewArray).Call(uintptr(len), uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return &ICefV8Value{
|
2023-03-13 10:50:45 +08:00
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
valueType: consts.V8vtArray,
|
|
|
|
|
valueByIndex: make([]*ICefV8Value, len),
|
2023-02-24 11:37:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
|
2023-02-25 12:01:31 +08:00
|
|
|
|
func (*cefV8Value) NewArrayBuffer(buffer []byte, callback *ICefV8ArrayBufferReleaseCallback) *ICefV8Value {
|
2023-02-24 11:37:39 +08:00
|
|
|
|
var bufLen = len(buffer)
|
|
|
|
|
if bufLen == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
if callback == nil {
|
2023-02-25 12:01:31 +08:00
|
|
|
|
callback = V8ArrayBufferReleaseCallbackRef.New()
|
2023-02-24 11:37:39 +08:00
|
|
|
|
}
|
|
|
|
|
var result uintptr
|
|
|
|
|
imports.Proc(internale_CefV8ValueRef_NewArrayBuffer).Call(uintptr(unsafe.Pointer(&buffer[0])), uintptr(int32(bufLen)), callback.Instance(), uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return &ICefV8Value{
|
2023-03-02 23:47:20 +08:00
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
valueType: consts.V8vtArrayBuffer,
|
2023-02-24 11:37:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-23 14:34:23 +08:00
|
|
|
|
|
2023-03-02 18:47:39 +08:00
|
|
|
|
// newFunction internal
|
|
|
|
|
func (*cefV8Value) newFunction(name string, handler *ICefV8Handler) *ICefV8Value {
|
2023-02-23 14:34:23 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
imports.Proc(internale_CefV8ValueRef_NewFunction).Call(api.PascalStr(name), handler.Instance(), uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return &ICefV8Value{
|
2023-03-02 23:47:20 +08:00
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
valueType: consts.V8vtFunction,
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 18:47:39 +08:00
|
|
|
|
// NewFunction export
|
|
|
|
|
func (m *cefV8Value) NewFunction(name string, handler *ICefV8Handler) *ICefV8Value {
|
2023-03-13 17:30:13 +08:00
|
|
|
|
if isIPCInternalKey(name) {
|
2023-03-02 18:47:39 +08:00
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return m.newFunction(name, handler)
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 12:01:31 +08:00
|
|
|
|
func (*cefV8Value) NewPromise() *ICefV8Value {
|
2023-02-23 14:34:23 +08:00
|
|
|
|
var result uintptr
|
|
|
|
|
imports.Proc(internale_CefV8ValueRef_NewPromise).Call(uintptr(unsafe.Pointer(&result)))
|
|
|
|
|
return &ICefV8Value{
|
2023-03-02 23:47:20 +08:00
|
|
|
|
instance: unsafe.Pointer(result),
|
|
|
|
|
valueType: consts.V8vtPromise,
|
2023-02-23 14:34:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-03 10:00:29 +08:00
|
|
|
|
|
2023-03-04 11:19:45 +08:00
|
|
|
|
// UnWrap 指针包裹引用
|
2023-03-04 11:58:35 +08:00
|
|
|
|
func (*cefV8Value) UnWrap(data *ICefV8Value) *ICefV8Value {
|
2023-03-04 11:19:45 +08:00
|
|
|
|
var result uintptr
|
2023-03-04 11:58:35 +08:00
|
|
|
|
imports.Proc(internale_CefV8ValueRef_UnWrap).Call(data.Instance(), uintptr(unsafe.Pointer(&result)))
|
2023-03-16 14:04:39 +08:00
|
|
|
|
data.base.Free(data.Instance())
|
2023-03-04 11:58:35 +08:00
|
|
|
|
data.instance = unsafe.Pointer(result)
|
|
|
|
|
return data
|
2023-03-04 11:19:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 10:00:29 +08:00
|
|
|
|
func (m *ICefV8ValueKeys) Count() int {
|
|
|
|
|
if m == nil || m.keys == nil {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
return m.count
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ICefV8ValueKeys) Get(index int) string {
|
|
|
|
|
if m == nil || m.keys == nil {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
2023-03-09 16:35:38 +08:00
|
|
|
|
count := m.Count()
|
|
|
|
|
if index < count {
|
2023-03-03 11:43:19 +08:00
|
|
|
|
if m.keyArray == nil {
|
2023-03-09 16:35:38 +08:00
|
|
|
|
m.keyArray = make([]string, count)
|
2023-03-03 11:43:19 +08:00
|
|
|
|
}
|
2023-03-09 16:35:38 +08:00
|
|
|
|
if len(m.keyArray) < count {
|
2023-03-03 11:43:19 +08:00
|
|
|
|
keyArray := m.keyArray
|
2023-03-09 16:35:38 +08:00
|
|
|
|
m.keyArray = make([]string, count)
|
2023-03-03 11:43:19 +08:00
|
|
|
|
copy(m.keyArray, keyArray)
|
|
|
|
|
}
|
|
|
|
|
value := m.keyArray[index]
|
|
|
|
|
if value == "" {
|
|
|
|
|
value = m.keys.Strings(int32(index))
|
|
|
|
|
m.keyArray[index] = value
|
|
|
|
|
}
|
|
|
|
|
return value
|
2023-03-03 10:00:29 +08:00
|
|
|
|
}
|
|
|
|
|
return ""
|
|
|
|
|
}
|
2023-03-09 16:35:38 +08:00
|
|
|
|
|
|
|
|
|
func (m *ICefV8ValueKeys) Free() {
|
|
|
|
|
if m == nil || m.keys == nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
m.keyArray = nil
|
|
|
|
|
m.keys.Free()
|
|
|
|
|
m.keys = nil
|
|
|
|
|
}
|