upgrade-dev v2.1.25

This commit is contained in:
杨红岩 2023-03-05 12:41:08 +08:00
parent 2df921fb7b
commit 424ae1db8c
4 changed files with 69 additions and 67 deletions

View File

@ -177,7 +177,7 @@ func ipcJSEmitGo(eventParam *rIPCEventParam, result *rGoResult, args uintptr) {
if bindType == IS_OBJECT {
name = name[len(internalObjectRootName)+1:]
}
if jsValue, ok := VariableBind.bindValue(name); ok {
if jsValue, ok := VariableBind.getBindValue(name); ok {
jsValue.Lock()
defer jsValue.UnLock()
if jsValue.ValueType().Jsv == V8_VALUE_FUNCTION { //func
@ -408,7 +408,7 @@ func internalBrowserIPCOnEventInit() {
args := context.Arguments()
defer args.Clear()
fullName := args.GetString(0)
var jsValue, ok = VariableBind.bindValue(fullName)
var jsValue, ok = VariableBind.getBindValue(fullName)
buf := &bytes.Buffer{}
defer buf.Reset()
if ok {
@ -430,7 +430,7 @@ func internalBrowserIPCOnEventInit() {
fullName := args.GetString(0)
item := args.Item(1)
newValueType := item.VTypeToJS()
jsValue, ok := VariableBind.bindValue(fullName)
jsValue, ok := VariableBind.getBindValue(fullName)
isSuccess := false
retArgs := ipc.NewArgumentList()
defer retArgs.Clear()
@ -461,7 +461,7 @@ func internalBrowserIPCOnEventInit() {
dataItems := args.RangeItems(0, args.Size()-1)
var inArgument = ipc.NewArgumentList()
inArgument.SetItems(dataItems)
var jsValue, ok = VariableBind.bindValue(fullName)
var jsValue, ok = VariableBind.getBindValue(fullName)
var (
outParams []reflect.Value
isSuccess bool

View File

@ -242,7 +242,7 @@ func v8BindFuncCallbackHandler(eventType BIND_EVENT, fullNamePtr uintptr, args u
}
fullName := api.GoStr(fullNamePtr)
exceptionPrt = (*uintptr)(getPtr(1))
var jsValue, ok = VariableBind.bindValue(fullName)
var jsValue, ok = VariableBind.getBindValue(fullName)
var fnInfo *funcInfo
if !ok {
errorMessage = cefErrorMessage(CVE_ERROR_NOT_FOUND_FUNC)

View File

@ -42,7 +42,7 @@ type IProvisionalBindStorage interface {
NewFunction(name string, fn interface{}) error //固定类型 - function
NewObjects(objects ...interface{}) //固定类型 - object - struct
Bind(name string, bind interface{}) error //固定类型 - 所有支持类型
bindValue(fullName string) (JSValue, bool) //
getBindValue(fullName string) (JSValue, bool) //
binds() map[string]JSValue //
bindCount() int //
callVariableBind(browser *ICefBrowser, frame *ICefFrame) //
@ -76,7 +76,9 @@ func (m *variableBind) removeBind(fullName string) {
delete(m.bindMapping, fullName)
}
func (m *variableBind) bindValue(fullName string) (JSValue, bool) {
func (m *variableBind) getBindValue(fullName string) (JSValue, bool) {
m.lock.Lock()
defer m.lock.Unlock()
value, ok := m.bindMapping[fullName]
return value, ok
}
@ -248,66 +250,66 @@ func (m *variableBind) Bind(name string, bind interface{}) error {
//isCommonObject: IS_OBJECT,
//eventId: uintptr(__bind_id()),
}
//类型信息
if jsv == V8_VALUE_FUNCTION && isMainProcess { //function
if info, err := checkFunc(typ, FN_TYPE_OBJECT); err == nil {
value.funcInfo = info
value.instance = unsafe.Pointer(&bind)
value.value = reflect.ValueOf(bind)
} else {
return err
}
} else if jsv == V8_VALUE_OBJECT { //object
if gov == GO_VALUE_STRUCT { // object - struct
} else if gov == GO_VALUE_MAP { // object - map
}
} else if jsv == V8_VALUE_ARRAY { //array
} else if isMainProcess { //field
switch jsv {
case V8_VALUE_STRING:
value.instance = unsafe.Pointer(bind.(*string))
case V8_VALUE_INT:
switch gov {
case GO_VALUE_INT:
value.instance = unsafe.Pointer(bind.(*int))
case GO_VALUE_INT8:
value.instance = unsafe.Pointer(bind.(*int8))
case GO_VALUE_INT16:
value.instance = unsafe.Pointer(bind.(*int16))
case GO_VALUE_INT32:
value.instance = unsafe.Pointer(bind.(*int32))
case GO_VALUE_INT64:
value.instance = unsafe.Pointer(bind.(*int64))
case GO_VALUE_UINT:
value.instance = unsafe.Pointer(bind.(*uint))
case GO_VALUE_UINT8:
value.instance = unsafe.Pointer(bind.(*uint8))
case GO_VALUE_UINT16:
value.instance = unsafe.Pointer(bind.(*uint16))
case GO_VALUE_UINT32:
value.instance = unsafe.Pointer(bind.(*uint32))
case GO_VALUE_UINT64:
value.instance = unsafe.Pointer(bind.(*uint64))
case GO_VALUE_UINTPTR:
value.instance = unsafe.Pointer(bind.(*uintptr))
}
case V8_VALUE_DOUBLE:
if gov == GO_VALUE_FLOAT32 {
value.instance = unsafe.Pointer(bind.(*float32))
} else {
value.instance = unsafe.Pointer(bind.(*float64))
}
case V8_VALUE_BOOLEAN:
value.instance = unsafe.Pointer(bind.(*bool))
default:
return errors.New("parameter type mismatch")
}
value.value = bind
}
if isMainProcess {
//类型信息
if jsv == V8_VALUE_FUNCTION { //function
if info, err := checkFunc(typ, FN_TYPE_OBJECT); err == nil {
value.funcInfo = info
value.instance = unsafe.Pointer(&bind)
value.value = reflect.ValueOf(bind)
} else {
return err
}
} else if jsv == V8_VALUE_OBJECT { //object
if gov == GO_VALUE_STRUCT { // object - struct
} else if gov == GO_VALUE_MAP { // object - map
}
} else if jsv == V8_VALUE_ARRAY { //array
} else { //field
switch jsv {
case V8_VALUE_STRING:
value.instance = unsafe.Pointer(bind.(*string))
case V8_VALUE_INT:
switch gov {
case GO_VALUE_INT:
value.instance = unsafe.Pointer(bind.(*int))
case GO_VALUE_INT8:
value.instance = unsafe.Pointer(bind.(*int8))
case GO_VALUE_INT16:
value.instance = unsafe.Pointer(bind.(*int16))
case GO_VALUE_INT32:
value.instance = unsafe.Pointer(bind.(*int32))
case GO_VALUE_INT64:
value.instance = unsafe.Pointer(bind.(*int64))
case GO_VALUE_UINT:
value.instance = unsafe.Pointer(bind.(*uint))
case GO_VALUE_UINT8:
value.instance = unsafe.Pointer(bind.(*uint8))
case GO_VALUE_UINT16:
value.instance = unsafe.Pointer(bind.(*uint16))
case GO_VALUE_UINT32:
value.instance = unsafe.Pointer(bind.(*uint32))
case GO_VALUE_UINT64:
value.instance = unsafe.Pointer(bind.(*uint64))
case GO_VALUE_UINTPTR:
value.instance = unsafe.Pointer(bind.(*uintptr))
}
case V8_VALUE_DOUBLE:
if gov == GO_VALUE_FLOAT32 {
value.instance = unsafe.Pointer(bind.(*float32))
} else {
value.instance = unsafe.Pointer(bind.(*float64))
}
case V8_VALUE_BOOLEAN:
value.instance = unsafe.Pointer(bind.(*bool))
default:
return errors.New("parameter type mismatch")
}
value.value = bind
}
value.that = value
}
m.addBind(name, value)

View File

@ -52,7 +52,7 @@
}
</script>
</head>
<body style="overflow: hidden;margin: 0px;padding: 0px;">
<body style="margin: 0px;padding: 0px;">
<p>
<h3>process-message</h3></p>
<p><a target="_blank" href="ipc-event.html">open</a></p>