5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 11:43:20 +08:00
wails/v2/internal/frontend/desktop/windows/go-webview2/pkg/combridge/iunknown.go
stffabi 0a20c8db96
[webview2loader] Add full featured go implementation (#1974)
* [webview2loader] Add full featured go implementation

The new go loader can be activated with the exp_gowebview2loader build tag.

* [build] Add information for using the new webvie2loader
2022-10-22 00:29:16 +11:00

55 lines
1.0 KiB
Go

package combridge
import (
"golang.org/x/sys/windows"
)
const iUnknownGUID = "{00000000-0000-0000-C000-000000000046}"
func init() {
registerVTableInternal[IUnknown, IUnknown](
iUnknownGUID,
true,
iUnknownQueryInterface,
iUnknownAddRef,
iUnknownRelease,
)
}
type IUnknown interface{}
func iUnknownQueryInterface(this uintptr, refiid *windows.GUID, ppvObject *uintptr) uintptr {
if refiid == nil || ppvObject == nil {
return uintptr(windows.E_INVALIDARG)
}
comIfcePointersL.RLock()
obj := comIfcePointers[this]
comIfcePointersL.RUnlock()
ref := obj.queryInterface(refiid.String(), true)
if ref != 0 {
*ppvObject = ref
return windows.NO_ERROR
}
*ppvObject = 0
return uintptr(windows.E_NOINTERFACE)
}
func iUnknownAddRef(this uintptr) uintptr {
comIfcePointersL.RLock()
obj := comIfcePointers[this]
comIfcePointersL.RUnlock()
return uintptr(obj.addRef())
}
func iUnknownRelease(this uintptr) uintptr {
comIfcePointersL.RLock()
obj := comIfcePointers[this]
comIfcePointersL.RUnlock()
return uintptr(obj.release())
}