Update dependencies
This commit is contained in:
7
vendor/github.com/dblohm7/wingoes/com/automation/automation.go
generated
vendored
Normal file
7
vendor/github.com/dblohm7/wingoes/com/automation/automation.go
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build windows
|
||||
|
||||
// Package automation provides essential types for interacting with COM Automation (IDispatch).
|
||||
package automation
|
||||
14
vendor/github.com/dblohm7/wingoes/com/automation/mksyscall.go
generated
vendored
Normal file
14
vendor/github.com/dblohm7/wingoes/com/automation/mksyscall.go
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build windows
|
||||
|
||||
package automation
|
||||
|
||||
//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go mksyscall.go
|
||||
//go:generate go run golang.org/x/tools/cmd/goimports -w zsyscall_windows.go
|
||||
|
||||
//sys sysAllocString(str *uint16) (ret BSTR) = oleaut32.SysAllocString
|
||||
//sys sysAllocStringLen(str *uint16, strLen uint32) (ret BSTR) = oleaut32.SysAllocStringLen
|
||||
//sys sysFreeString(bstr BSTR) = oleaut32.SysFreeString
|
||||
//sys sysStringLen(bstr BSTR) (ret uint32) = oleaut32.SysStringLen
|
||||
93
vendor/github.com/dblohm7/wingoes/com/automation/types.go
generated
vendored
Normal file
93
vendor/github.com/dblohm7/wingoes/com/automation/types.go
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build windows
|
||||
|
||||
package automation
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
// BSTR is the string format used by COM Automation. They are not garbage
|
||||
// collected and must be explicitly closed when no longer needed.
|
||||
type BSTR uintptr
|
||||
|
||||
// NewBSTR creates a new BSTR from string s.
|
||||
func NewBSTR(s string) BSTR {
|
||||
buf, err := windows.UTF16FromString(s)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return NewBSTRFromUTF16(buf)
|
||||
}
|
||||
|
||||
// NewBSTR creates a new BSTR from slice us, which contains UTF-16 code units.
|
||||
func NewBSTRFromUTF16(us []uint16) BSTR {
|
||||
if len(us) == 0 {
|
||||
return 0
|
||||
}
|
||||
return sysAllocStringLen(unsafe.SliceData(us), uint32(len(us)))
|
||||
}
|
||||
|
||||
// NewBSTR creates a new BSTR from up, a C-style string pointer to UTF-16 code units.
|
||||
func NewBSTRFromUTF16Ptr(up *uint16) BSTR {
|
||||
if up == nil {
|
||||
return 0
|
||||
}
|
||||
return sysAllocString(up)
|
||||
}
|
||||
|
||||
// Len returns the length of bs in code units.
|
||||
func (bs *BSTR) Len() uint32 {
|
||||
return sysStringLen(*bs)
|
||||
}
|
||||
|
||||
// String returns the contents of bs as a Go string.
|
||||
func (bs *BSTR) String() string {
|
||||
return windows.UTF16ToString(bs.toUTF16())
|
||||
}
|
||||
|
||||
// toUTF16 is unsafe for general use because it returns a pointer that is
|
||||
// not managed by the Go GC.
|
||||
func (bs *BSTR) toUTF16() []uint16 {
|
||||
return unsafe.Slice(bs.toUTF16Ptr(), bs.Len())
|
||||
}
|
||||
|
||||
// ToUTF16 returns the contents of bs as a slice of UTF-16 code units.
|
||||
func (bs *BSTR) ToUTF16() []uint16 {
|
||||
return append([]uint16{}, bs.toUTF16()...)
|
||||
}
|
||||
|
||||
// toUTF16Ptr is unsafe for general use because it returns a pointer that is
|
||||
// not managed by the Go GC.
|
||||
func (bs *BSTR) toUTF16Ptr() *uint16 {
|
||||
return (*uint16)(unsafe.Pointer(*bs))
|
||||
}
|
||||
|
||||
// ToUTF16 returns the contents of bs as C-style string pointer to UTF-16 code units.
|
||||
func (bs *BSTR) ToUTF16Ptr() *uint16 {
|
||||
return unsafe.SliceData(bs.ToUTF16())
|
||||
}
|
||||
|
||||
// Clone creates a clone of bs whose lifetime becomes independent of the original.
|
||||
// It must be explicitly closed when no longer needed.
|
||||
func (bs *BSTR) Clone() BSTR {
|
||||
return sysAllocStringLen(bs.toUTF16Ptr(), bs.Len())
|
||||
}
|
||||
|
||||
// IsNil returns true if bs holds a nil value.
|
||||
func (bs *BSTR) IsNil() bool {
|
||||
return *bs == 0
|
||||
}
|
||||
|
||||
// Close frees bs.
|
||||
func (bs *BSTR) Close() error {
|
||||
if *bs != 0 {
|
||||
sysFreeString(*bs)
|
||||
*bs = 0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
70
vendor/github.com/dblohm7/wingoes/com/automation/zsyscall_windows.go
generated
vendored
Normal file
70
vendor/github.com/dblohm7/wingoes/com/automation/zsyscall_windows.go
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
// Code generated by 'go generate'; DO NOT EDIT.
|
||||
|
||||
package automation
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
var _ unsafe.Pointer
|
||||
|
||||
// Do the interface allocations only once for common
|
||||
// Errno values.
|
||||
const (
|
||||
errnoERROR_IO_PENDING = 997
|
||||
)
|
||||
|
||||
var (
|
||||
errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
|
||||
errERROR_EINVAL error = syscall.EINVAL
|
||||
)
|
||||
|
||||
// errnoErr returns common boxed Errno values, to prevent
|
||||
// allocations at runtime.
|
||||
func errnoErr(e syscall.Errno) error {
|
||||
switch e {
|
||||
case 0:
|
||||
return errERROR_EINVAL
|
||||
case errnoERROR_IO_PENDING:
|
||||
return errERROR_IO_PENDING
|
||||
}
|
||||
// TODO: add more here, after collecting data on the common
|
||||
// error values see on Windows. (perhaps when running
|
||||
// all.bat?)
|
||||
return e
|
||||
}
|
||||
|
||||
var (
|
||||
modoleaut32 = windows.NewLazySystemDLL("oleaut32.dll")
|
||||
|
||||
procSysAllocString = modoleaut32.NewProc("SysAllocString")
|
||||
procSysAllocStringLen = modoleaut32.NewProc("SysAllocStringLen")
|
||||
procSysFreeString = modoleaut32.NewProc("SysFreeString")
|
||||
procSysStringLen = modoleaut32.NewProc("SysStringLen")
|
||||
)
|
||||
|
||||
func sysAllocString(str *uint16) (ret BSTR) {
|
||||
r0, _, _ := syscall.Syscall(procSysAllocString.Addr(), 1, uintptr(unsafe.Pointer(str)), 0, 0)
|
||||
ret = BSTR(r0)
|
||||
return
|
||||
}
|
||||
|
||||
func sysAllocStringLen(str *uint16, strLen uint32) (ret BSTR) {
|
||||
r0, _, _ := syscall.Syscall(procSysAllocStringLen.Addr(), 2, uintptr(unsafe.Pointer(str)), uintptr(strLen), 0)
|
||||
ret = BSTR(r0)
|
||||
return
|
||||
}
|
||||
|
||||
func sysFreeString(bstr BSTR) {
|
||||
syscall.Syscall(procSysFreeString.Addr(), 1, uintptr(bstr), 0, 0)
|
||||
return
|
||||
}
|
||||
|
||||
func sysStringLen(bstr BSTR) (ret uint32) {
|
||||
r0, _, _ := syscall.Syscall(procSysStringLen.Addr(), 1, uintptr(bstr), 0, 0)
|
||||
ret = uint32(r0)
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user