Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
d31a4487
energy
项目概览
energye
/
energy
通知
13
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
energy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d31a4487
编写于
3月 18, 2023
作者:
yanghye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
upgrade-dev v2.3.13
上级
4b08cfbc
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
79 addition
and
50 deletion
+79
-50
cef/cef-application-callback.go
cef/cef-application-callback.go
+0
-2
cef/cef-ipc-browser.go
cef/cef-ipc-browser.go
+5
-14
cef/cef-ipc-render.go
cef/cef-ipc-render.go
+22
-21
cef/cef-ipc-value-convert.go
cef/cef-ipc-value-convert.go
+7
-1
cef/cef-proc-def.go
cef/cef-proc-def.go
+4
-0
cef/cef-types-v8-value.go
cef/cef-types-v8-value.go
+40
-11
example/dev-test/ipc-event/ipc-event.go
example/dev-test/ipc-event/ipc-event.go
+1
-1
未找到文件。
cef/cef-application-callback.go
浏览文件 @
d31a4487
...
...
@@ -30,7 +30,6 @@ func appMainRunCallback() {
// renderProcessMessageReceived 渲染进程消息 - 默认实现
func
renderProcessMessageReceived
(
browser
*
ICefBrowser
,
frame
*
ICefFrame
,
sourceProcess
consts
.
CefProcessId
,
message
*
ICefProcessMessage
)
(
result
bool
)
{
fmt
.
Println
(
"render name"
,
message
.
Name
())
if
message
.
Name
()
==
internalProcessMessageIPCEmitReply
{
result
=
ipcRender
.
ipcJSExecuteGoEventMessageReply
(
browser
,
frame
,
sourceProcess
,
message
)
}
else
if
message
.
Name
()
==
internalProcessMessageIPCOn
{
...
...
@@ -41,7 +40,6 @@ func renderProcessMessageReceived(browser *ICefBrowser, frame *ICefFrame, source
// browserProcessMessageReceived 主进程消息 - 默认实现
func
browserProcessMessageReceived
(
browser
*
ICefBrowser
,
frame
*
ICefFrame
,
sourceProcess
consts
.
CefProcessId
,
message
*
ICefProcessMessage
)
(
result
bool
)
{
fmt
.
Println
(
"browser name"
,
message
.
Name
())
if
message
.
Name
()
==
internalProcessMessageIPCEmit
{
result
=
ipcBrowser
.
ipcGoExecuteMethodMessage
(
browser
,
frame
,
sourceProcess
,
message
)
}
else
if
message
.
Name
()
==
internalProcessMessageIPCOn
{
...
...
cef/cef-ipc-browser.go
浏览文件 @
d31a4487
...
...
@@ -84,14 +84,15 @@ func (m *ipcBrowserProcess) ipcGoExecuteMethodMessage(browser *ICefBrowser, fram
messageId
=
int32
(
argument
.
GetIntByKey
(
ipc_id
))
emitName
=
argument
.
GetStringByKey
(
ipc_event
)
argumentList
=
argument
.
GetArrayByKey
(
ipc_argumentList
)
messageDataBytes
=
nil
}
defer
func
()
{
if
argument
!=
nil
{
argument
.
Free
()
}
if
argumentList
!=
nil
{
argumentList
.
Free
()
}
if
argument
!=
nil
{
argument
.
Free
()
}
}()
argumentListBytes
=
nil
eventCallback
:=
ipc
.
CheckOnEvent
(
emitName
)
...
...
@@ -106,8 +107,6 @@ func (m *ipcBrowserProcess) ipcGoExecuteMethodMessage(browser *ICefBrowser, fram
argsCallback
.
Invoke
(
ipcContext
)
}
if
messageId
!=
0
{
// 回调函数处理
//replyMessage := ProcessMessageRef.new(internalProcessMessageIPCEmitReply)
//replyMessage.ArgumentList().SetInt(0, messageId)
replyMessage
:=
json
.
NewJSONArray
(
nil
)
replyMessage
.
Add
(
messageId
)
replyMessage
.
Add
(
false
)
...
...
@@ -116,27 +115,19 @@ func (m *ipcBrowserProcess) ipcGoExecuteMethodMessage(browser *ICefBrowser, fram
if
replay
.
Result
()
!=
nil
&&
len
(
replay
.
Result
())
>
0
{
switch
replay
.
Result
()[
0
]
.
(
type
)
{
case
[]
byte
:
//binaryValue := BinaryValueRef.New((replay.Result()[0]).([]byte))
//replyMessage.ArgumentList().SetBool(1, true) //有返回值
//replyMessage.ArgumentList().SetBinary(2, binaryValue) //result []byte
replyMessage
.
SetByIndex
(
1
,
true
)
replyMessage
.
Add
((
replay
.
Result
()[
0
])
.
([]
byte
))
default
:
//replyMessage.ArgumentList().SetBool(1, false) //无返回值
}
}
else
{
//replyMessage.ArgumentList().SetBool(1, false) //无返回值
}
//frame.SendProcessMessage(consts.PID_RENDER, replyMessage)
frame
.
SendProcessMessageForJSONBytes
(
internalProcessMessageIPCEmitReply
,
consts
.
PID_RENDER
,
replyMessage
.
Bytes
())
replyMessage
.
Free
()
replay
.
Clear
()
//replyMessage.Free()
}
if
ipcContext
.
ArgumentList
()
!=
nil
{
ipcContext
.
ArgumentList
()
.
Free
()
}
ipcContext
.
Result
(
nil
)
return
}
...
...
cef/cef-ipc-render.go
浏览文件 @
d31a4487
...
...
@@ -232,7 +232,7 @@ func (m *ipcRenderProcess) ipcJSExecuteGoEvent(name string, object *ICefV8Value,
context
:=
V8ContextRef
.
Current
()
var
messageId
int32
=
0
//回调函数
if
emitCallback
!=
nil
&&
false
{
if
emitCallback
!=
nil
{
//回调函数临时存放到缓存中
emitCallback
.
SetCanNotFree
(
true
)
messageId
=
ipcRender
.
emitHandler
.
addCallback
(
&
ipcCallback
{
...
...
@@ -247,10 +247,11 @@ func (m *ipcRenderProcess) ipcJSExecuteGoEvent(name string, object *ICefV8Value,
message
.
Set
(
ipc_id
,
messageId
)
message
.
Set
(
ipc_event
,
emitNameValue
)
message
.
Set
(
ipc_argumentList
,
json
.
NewJSONArray
(
args
)
.
Data
())
//
frame.SendProcessMessageForJSONBytes(internalProcessMessageIPCEmit, consts.PID_BROWSER, message.Bytes())
frame
.
SendProcessMessageForJSONBytes
(
internalProcessMessageIPCEmit
,
consts
.
PID_BROWSER
,
message
.
Bytes
())
message
.
Free
()
frame
.
Free
()
context
.
Free
()
// TODO dev
args
=
nil
//context.Free() // TODO dev
retVal
.
SetResult
(
V8ValueRef
.
NewBool
(
true
))
}
return
...
...
@@ -259,7 +260,6 @@ func (m *ipcRenderProcess) ipcJSExecuteGoEvent(name string, object *ICefV8Value,
// ipcJSExecuteGoEventMessageReply JS执行Go监听,Go的消息回复
func
(
m
*
ipcRenderProcess
)
ipcJSExecuteGoEventMessageReply
(
browser
*
ICefBrowser
,
frame
*
ICefFrame
,
sourceProcess
consts
.
CefProcessId
,
message
*
ICefProcessMessage
)
(
result
bool
)
{
result
=
true
//messageId := message.ArgumentList().GetInt(0)
argumentListBytes
:=
message
.
ArgumentList
()
.
GetBinary
(
0
)
var
messageDataBytes
[]
byte
if
argumentListBytes
.
IsValid
()
{
...
...
@@ -272,34 +272,35 @@ func (m *ipcRenderProcess) ipcJSExecuteGoEventMessageReply(browser *ICefBrowser,
return
}
}
var
messageId
int32
var
isReturnArgs
bool
var
argumentList
json
.
JSONArray
var
(
messageId
int32
isReturnArgs
bool
argumentList
json
.
JSONArray
)
if
messageDataBytes
!=
nil
{
argumentList
=
json
.
NewJSONArray
(
messageDataBytes
)
messageId
=
int32
(
argumentList
.
GetIntByIndex
(
0
))
isReturnArgs
=
argumentList
.
GetBoolByIndex
(
1
)
messageDataBytes
=
nil
}
defer
func
()
{}()
defer
func
()
{
if
argumentList
!=
nil
{
argumentList
.
Free
()
}
}()
fmt
.
Println
(
"messageId"
,
messageId
,
isReturnArgs
)
if
callback
:=
ipcRender
.
emitHandler
.
getCallback
(
messageId
);
callback
!=
nil
{
callback
.
function
.
SetCanNotFree
(
false
)
//第二个参数 true 有返回参数
if
isReturnArgs
{
//[]byte
//returnArgs := argumentList.GetArrayByIndex(2)
//fmt.Println("returnArgs", argumentList.GetArrayByIndex(2).ToJSONString())
returnArgs
:=
argumentList
.
GetArrayByIndex
(
2
)
//解析 '[]byte' 参数
//if callback.context.Enter() {
// if args, err := ipcValueConvert.BytesToV8ArrayValue(resultArgsBytes); err == nil {
// callback.function.ExecuteFunctionWithContext(callback.context, nil, args).Free()
// args.Free()
// } else {
// // parsing error
// callback.function.ExecuteFunctionWithContext(callback.context, nil, nil).Free()
// }
//}
//callback.context.Exit()
if
callback
.
context
.
Enter
()
{
callback
.
function
.
ExecuteFunctionWithContextForArgsBytes
(
callback
.
context
,
nil
,
returnArgs
.
Bytes
())
.
Free
()
callback
.
context
.
Exit
()
}
returnArgs
.
Free
()
}
else
{
//无返回参数
if
callback
.
context
.
Enter
()
{
callback
.
function
.
ExecuteFunctionWithContext
(
callback
.
context
,
nil
,
nil
)
.
Free
()
...
...
cef/cef-ipc-value-convert.go
浏览文件 @
d31a4487
...
...
@@ -15,6 +15,7 @@ package cef
import
(
"errors"
"fmt"
"github.com/energye/energy/common/imports"
"github.com/energye/energy/consts"
"github.com/energye/energy/pkgs/json"
...
...
@@ -563,10 +564,15 @@ func (m *v8ValueProcessMessageConvert) BytesToV8ValueArray(data []byte) *TCefV8V
var
result
uintptr
var
resultLength
uintptr
imports
.
Proc
(
internale_ValueConvert_BytesToV8ValueArray
)
.
Call
(
uintptr
(
unsafe
.
Pointer
(
&
data
[
0
])),
uintptr
(
uint32
(
len
(
data
))),
uintptr
(
unsafe
.
Pointer
(
&
result
)),
uintptr
(
unsafe
.
Pointer
(
&
resultLength
)))
fmt
.
Println
(
"result"
,
result
,
resultLength
)
if
result
==
0
||
resultLength
==
0
{
return
nil
}
return
&
TCefV8ValueArray
{
instance
:
unsafe
.
Pointer
(
result
),
argumentsLength
:
int
(
resultLength
)}
v
:=
&
TCefV8ValueArray
{
instance
:
unsafe
.
Pointer
(
result
),
arguments
:
result
,
argumentsLength
:
int
(
resultLength
)
/*, argumentsCollect: make([]*ICefV8Value, int(resultLength))*/
}
//for i := 0; i < v.argumentsLength; i++ {
// v.Get(i)
//}
return
v
}
// JSONArrayToV8ValueArray 转换 TCefV8ValueArray
...
...
cef/cef-proc-def.go
浏览文件 @
d31a4487
...
...
@@ -865,6 +865,7 @@ func init() {
dllimports
.
NewEnergyImport
(
"CefV8Value_GetFunctionHandler"
,
0
),
dllimports
.
NewEnergyImport
(
"CefV8Value_ExecuteFunction"
,
0
),
dllimports
.
NewEnergyImport
(
"CefV8Value_ExecuteFunctionWithContext"
,
0
),
dllimports
.
NewEnergyImport
(
"CefV8Value_ExecuteFunctionWithContextForArgsBytes"
,
0
),
dllimports
.
NewEnergyImport
(
"CefV8Value_ResolvePromise"
,
0
),
dllimports
.
NewEnergyImport
(
"CefV8Value_RejectPromise"
,
0
),
dllimports
.
NewEnergyImport
(
"CefV8Value_Free"
,
0
),
...
...
@@ -1102,6 +1103,7 @@ func init() {
dllimports
.
NewEnergyImport
(
"ValueConvert_BytesToListValue"
,
0
),
dllimports
.
NewEnergyImport
(
"ValueConvert_BytesToDictionaryValue"
,
0
),
dllimports
.
NewEnergyImport
(
"ValueConvert_BytesToV8ValueArray"
,
0
),
dllimports
.
NewEnergyImport
(
"ValueConvert_BytesToV8ValueArrayFree"
,
0
),
dllimports
.
NewEnergyImport
(
"ValueConvert_BytesToV8Array"
,
0
),
dllimports
.
NewEnergyImport
(
"ValueConvert_BytesToV8Object"
,
0
),
}
...
...
@@ -1956,6 +1958,7 @@ const (
internale_CefV8Value_GetFunctionHandler
internale_CefV8Value_ExecuteFunction
internale_CefV8Value_ExecuteFunctionWithContext
internale_CefV8Value_ExecuteFunctionWithContextForArgsBytes
internale_CefV8Value_ResolvePromise
internale_CefV8Value_RejectPromise
internale_CefV8Value_Free
...
...
@@ -2193,6 +2196,7 @@ const (
internale_ValueConvert_BytesToListValue
internale_ValueConvert_BytesToDictionaryValue
internale_ValueConvert_BytesToV8ValueArray
internale_ValueConvert_BytesToV8ValueArrayFree
internale_ValueConvert_BytesToV8Array
internale_ValueConvert_BytesToV8Object
)
cef/cef-types-v8-value.go
浏览文件 @
d31a4487
...
...
@@ -490,15 +490,15 @@ func (m *ICefV8Value) GetFunctionHandler() *ICefV8Handler {
func
(
m
*
ICefV8Value
)
ExecuteFunction
(
obj
*
ICefV8Value
,
arguments
*
TCefV8ValueArray
)
*
ICefV8Value
{
var
result
uintptr
var
ptr
uintptr
if
arguments
.
Size
()
>
0
{
var
argumentsPtr
=
arguments
.
Instance
()
if
arguments
.
Size
()
>
0
/*&& arguments.argumentsCollect != nil*/
{
var
args
=
make
([]
uintptr
,
arguments
.
Size
(),
arguments
.
Size
())
for
i
,
a
:=
range
arguments
.
argumentsCollect
{
args
[
i
]
=
a
.
Instance
()
}
p
tr
=
uintptr
(
unsafe
.
Pointer
(
&
args
[
0
]))
argumentsP
tr
=
uintptr
(
unsafe
.
Pointer
(
&
args
[
0
]))
}
imports
.
Proc
(
internale_CefV8Value_ExecuteFunction
)
.
Call
(
m
.
Instance
(),
obj
.
Instance
(),
uintptr
(
unsafe
.
Pointer
(
&
result
)),
p
tr
,
uintptr
(
int32
(
arguments
.
Size
())))
imports
.
Proc
(
internale_CefV8Value_ExecuteFunction
)
.
Call
(
m
.
Instance
(),
obj
.
Instance
(),
uintptr
(
unsafe
.
Pointer
(
&
result
)),
argumentsP
tr
,
uintptr
(
int32
(
arguments
.
Size
())))
return
&
ICefV8Value
{
instance
:
unsafe
.
Pointer
(
result
),
}
...
...
@@ -506,15 +506,25 @@ func (m *ICefV8Value) ExecuteFunction(obj *ICefV8Value, arguments *TCefV8ValueAr
func
(
m
*
ICefV8Value
)
ExecuteFunctionWithContext
(
v8Context
*
ICefV8Context
,
obj
*
ICefV8Value
,
arguments
*
TCefV8ValueArray
)
*
ICefV8Value
{
var
result
uintptr
var
ptr
uintptr
if
arguments
.
Size
()
>
0
{
var
argumentsPtr
=
arguments
.
Instance
()
if
arguments
.
Size
()
>
0
&&
arguments
.
argumentsCollect
!=
nil
{
var
args
=
make
([]
uintptr
,
arguments
.
Size
(),
arguments
.
Size
())
for
i
,
a
:=
range
arguments
.
argumentsCollect
{
args
[
i
]
=
a
.
Instance
()
for
i
,
v
:=
range
arguments
.
argumentsCollect
{
args
[
i
]
=
v
.
Instance
()
}
p
tr
=
uintptr
(
unsafe
.
Pointer
(
&
args
[
0
]))
argumentsP
tr
=
uintptr
(
unsafe
.
Pointer
(
&
args
[
0
]))
}
imports
.
Proc
(
internale_CefV8Value_ExecuteFunctionWithContext
)
.
Call
(
m
.
Instance
(),
v8Context
.
Instance
(),
obj
.
Instance
(),
uintptr
(
unsafe
.
Pointer
(
&
result
)),
ptr
,
uintptr
(
int32
(
arguments
.
Size
())))
imports
.
Proc
(
internale_CefV8Value_ExecuteFunctionWithContext
)
.
Call
(
m
.
Instance
(),
v8Context
.
Instance
(),
obj
.
Instance
(),
uintptr
(
unsafe
.
Pointer
(
&
result
)),
argumentsPtr
,
uintptr
(
int32
(
arguments
.
Size
())))
return
&
ICefV8Value
{
instance
:
unsafe
.
Pointer
(
result
),
}
}
func
(
m
*
ICefV8Value
)
ExecuteFunctionWithContextForArgsBytes
(
v8Context
*
ICefV8Context
,
obj
*
ICefV8Value
,
arguments
[]
byte
)
*
ICefV8Value
{
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
)))
return
&
ICefV8Value
{
instance
:
unsafe
.
Pointer
(
result
),
}
...
...
@@ -536,6 +546,21 @@ func (m *ICefV8Value) SetCanNotFree(v bool) {
func
(
m
*
ICefV8Value
)
Free
()
{
if
m
.
instance
!=
nil
{
//if m.IsArray() {
// for i := 0; i < m.GetArrayLength(); i++ {
// if v := m.GetValueByIndex(i); v != nil {
// v.Free()
// }
// }
//}
//if m.IsObject() {
// keys := m.GetKeys()
// for i := 0; i < keys.Count(); i++ {
// if v := m.getValueByKey(keys.Get(i)); v != nil {
// v.Free()
// }
// }
//}
if
m
.
valueByIndex
!=
nil
{
for
_
,
v
:=
range
m
.
valueByIndex
{
if
v
!=
nil
{
...
...
@@ -620,12 +645,16 @@ func (m *TCefV8ValueArray) Free() {
}
if
m
.
argumentsCollect
!=
nil
{
for
_
,
v
:=
range
m
.
argumentsCollect
{
if
v
!=
nil
&&
v
.
instance
!=
nil
{
if
v
!=
nil
{
v
.
Free
()
}
}
m
.
argumentsCollect
=
nil
}
if
m
.
instance
!=
nil
{
//var ptr = m.Instance()
//imports.Proc(internale_ValueConvert_BytesToV8ValueArrayFree).Call(uintptr(unsafe.Pointer(&ptr)))
}
m
.
instance
=
nil
m
.
arguments
=
0
m
.
argumentsLength
=
0
...
...
example/dev-test/ipc-event/ipc-event.go
浏览文件 @
d31a4487
...
...
@@ -114,7 +114,7 @@ func main() {
ipc
.
On
(
"testEmitName"
,
func
(
context
ipc
.
IContext
)
{
testEmitName
++
argument
:=
context
.
ArgumentList
()
fmt
.
Println
(
"testEmitName"
,
argument
.
Size
(),
context
.
BrowserId
(),
context
.
FrameId
(),
testEmitName
)
//
fmt.Println("testEmitName", argument.Size(), context.BrowserId(), context.FrameId(), testEmitName)
//fmt.Println("data:", argument.GetByIndex(1).Data())
for
i
:=
0
;
i
<
argument
.
Size
();
i
++
{
argument
.
GetByIndex
(
i
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录