From 2476024f28f05ed16eaca37a0dcf5a4b4bf98e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E7=BA=A2=E5=B2=A9?= Date: Fri, 3 Mar 2023 10:00:29 +0800 Subject: [PATCH] upgrade-dev v2.1.15 --- cef/cef-application-callback.go | 3 +++ cef/cef-types-v8-value.go | 28 ++++++++++++++++++++++++---- cef/cef-types.go | 7 +++++++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/cef/cef-application-callback.go b/cef/cef-application-callback.go index c5d4e2da..138f27c4 100644 --- a/cef/cef-application-callback.go +++ b/cef/cef-application-callback.go @@ -84,6 +84,8 @@ func (m *contextCreate) makeIPC(context *ICefV8Context) { // ipcEmitExecute ipc.emit 执行 func (m *contextCreate) ipcEmitExecute(name string, object *ICefV8Value, arguments *TCefV8ValueArray, retVal *ResultV8Value, exception *Exception) bool { fmt.Println("emit handler name:", name, "arguments-size:", arguments.Size()) + keyList := object.GetKeys() + fmt.Println("\tkeys:", keyList, keyList.Count(), keyList.Get(0), keyList.Get(1)) if name != internalEmit { return false } @@ -123,6 +125,7 @@ func (m *contextCreate) ipcEmitExecute(name string, object *ICefV8Value, argumen if emitArgs != nil { argsLen := emitArgs.GetArrayLength() for i := 0; i < argsLen; i++ { + //emitArgs.GetValueByKey() fmt.Println("\temitArgs:", i, emitArgs.GetValueByIndex(i), emitArgs.GetValueByIndex(i).IsString()) } } diff --git a/cef/cef-types-v8-value.go b/cef/cef-types-v8-value.go index 7e57d7f6..969642f6 100644 --- a/cef/cef-types-v8-value.go +++ b/cef/cef-types-v8-value.go @@ -15,6 +15,7 @@ import ( "github.com/energye/energy/common" "github.com/energye/energy/common/imports" "github.com/energye/energy/consts" + "github.com/energye/golcl/lcl" "github.com/energye/golcl/lcl/api" "time" "unsafe" @@ -329,6 +330,7 @@ func (m *ICefV8Value) getValueByKey(key string) *ICefV8Value { // GetValueByKey export func (m *ICefV8Value) GetValueByKey(key string) *ICefV8Value { + // TODO 优化 if key == internalIPCKey { return nil } @@ -398,10 +400,11 @@ func (m *ICefV8Value) SetValueByAccessor(key string, settings consts.TCefV8Acces return m.setValueByAccessor(key, settings, attribute) } -//func (m *ICefV8Value) GetKeys(keys *lcl.TStrings) int32 { -// r1, _, _ := imports.Proc(internale_CefV8Value_GetKeys).Call(m.Instance(), keys.Instance()) -// return int32(r1) -//} +func (m *ICefV8Value) GetKeys() *ICefV8ValueKeys { + 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))} +} func (m *ICefV8Value) SetUserData(data *ICefV8Value) bool { r1, _, _ := imports.Proc(internale_CefV8Value_SetUserData).Call(m.Instance(), data.Instance()) @@ -657,3 +660,20 @@ func (*cefV8Value) NewPromise() *ICefV8Value { valueType: consts.V8vtPromise, } } + +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 "" + } + if index < m.Count() { + return m.keys.Strings(int32(index)) + } + return "" +} diff --git a/cef/cef-types.go b/cef/cef-types.go index 5754ed6e..4903cf07 100644 --- a/cef/cef-types.go +++ b/cef/cef-types.go @@ -14,6 +14,7 @@ package cef import ( . "github.com/energye/energy/consts" . "github.com/energye/energy/types" + "github.com/energye/golcl/lcl" "time" "unsafe" ) @@ -321,6 +322,12 @@ type ICefV8Value struct { valueMaps map[int]*ICefV8Value } +// ICefV8ValueKeys +type ICefV8ValueKeys struct { + keys *lcl.TStrings + count int +} + // TCefV8ValueArray ICefV8Value 数组的替代结构 type TCefV8ValueArray struct { instance unsafe.Pointer