mirror of
https://gitee.com/energye/energy.git
synced 2024-12-02 11:47:37 +08:00
upgrade-dev v2.1.8
This commit is contained in:
parent
f893b79372
commit
61ff65010a
@ -300,6 +300,12 @@ type ICefV8Exception struct {
|
||||
}
|
||||
|
||||
// ICefV8Context
|
||||
//
|
||||
// v8上下文对象
|
||||
//
|
||||
// 生命周期
|
||||
// 1. 在回调函数中有效
|
||||
// 2. 回调函数外使用 cef.V8ContextRef.Current() 获取上下文对象
|
||||
type ICefV8Context struct {
|
||||
instance unsafe.Pointer
|
||||
}
|
||||
|
@ -104,19 +104,19 @@ func main() {
|
||||
return true
|
||||
})
|
||||
handler.Execute(func(name string, object *cef.ICefV8Value, arguments *cef.TCefV8ValueArray, retVal *cef.ResultV8Value, exception *cef.Exception) bool {
|
||||
fmt.Println("handler", arguments.Size(), arguments.Get(3))
|
||||
fmt.Println("handler.Execute", arguments.Size(), arguments.Get(3))
|
||||
fmt.Println(arguments.Get(0).IsValid(), arguments.Get(0).GetStringValue())
|
||||
fmt.Println(arguments.Get(1).IsValid(), arguments.Get(1).GetIntValue())
|
||||
retVal.SetResult(cef.V8ValueRef.NewString("函数返回值?"))
|
||||
val, ex, ok := context.Eval("fntest();", "", 0)
|
||||
fmt.Println("Execute eval fntest:", val, ex, ok)
|
||||
val, ex, ok := cef.V8ContextRef.Current().Eval("fntest()", "", 0)
|
||||
fmt.Println("? = Execute eval fntest:", val, ex, ok)
|
||||
if ok {
|
||||
fmt.Println("Execute eval fntest-return-value:", val.GetStringValue())
|
||||
|
||||
fmt.Println("OK = Execute eval fntest-return-value:", val.GetStringValue())
|
||||
}
|
||||
val, ex, ok = context.Eval("errtest();", "", 0)
|
||||
fmt.Println("Execute errtest:", val, ex, ok)
|
||||
fmt.Println("Execute errtest-error:", ex.Message(), ex.LineNumber())
|
||||
|
||||
val, ex, ok = cef.V8ContextRef.Current().Eval("errtest();", "", 0)
|
||||
fmt.Println("? = Execute errtest:", val, ex, ok)
|
||||
fmt.Println("OK = Execute errtest-error:", ex.Message(), ex.LineNumber())
|
||||
fmt.Println("V8ContextRef.Current()", cef.V8ContextRef.Current().Global().GetValueByKey("arrBuf").IsArrayBuffer())
|
||||
fmt.Println("V8ContextRef.Entered()", cef.V8ContextRef.Entered().Global().GetValueByKey("arrBuf").IsArrayBuffer())
|
||||
return true
|
||||
|
@ -4,6 +4,20 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>bind</title>
|
||||
<script type="application/javascript">
|
||||
|
||||
function fntest() {
|
||||
console.log('fntest')
|
||||
return "返回fntest";
|
||||
}
|
||||
|
||||
function errtest() {
|
||||
console.log('errtest')
|
||||
let s = 1 / 0;
|
||||
throw {
|
||||
code: -1,
|
||||
msg: '类型错误'
|
||||
}
|
||||
}
|
||||
window.onload = function () {
|
||||
let doc = document.getElementById("test");
|
||||
|
||||
@ -36,18 +50,6 @@
|
||||
test(bufdata);
|
||||
console.log(arrBufa)
|
||||
}
|
||||
|
||||
function fntest() {
|
||||
return "返回fntest";
|
||||
}
|
||||
|
||||
function errtest() {
|
||||
let s = 1 / 0;
|
||||
throw {
|
||||
code: -1,
|
||||
msg: '类型错误'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body style="overflow: hidden;margin: 0px;padding: 0px;">
|
||||
|
Loading…
Reference in New Issue
Block a user