Skip to content

Commit

Permalink
Update dependency win32api to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
zzl committed Jan 29, 2023
1 parent 4ac05a2 commit 51c6c3f
Show file tree
Hide file tree
Showing 33 changed files with 216 additions and 164 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ vendor/
.idea/
_test/
_bak/

go.work
2 changes: 1 addition & 1 deletion com/bstr.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"syscall"
"unsafe"

"github.com/zzl/go-win32api/win32"
"github.com/zzl/go-win32api/v2/win32"
)

type BStr struct {
Expand Down
2 changes: 1 addition & 1 deletion com/comimpl/IClassFactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package comimpl

import (
"github.com/zzl/go-com/com"
"github.com/zzl/go-win32api/win32"
"github.com/zzl/go-win32api/v2/win32"
"syscall"
"unsafe"
)
Expand Down
39 changes: 27 additions & 12 deletions com/comimpl/IDataObject.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"unsafe"

"github.com/zzl/go-com/com"
"github.com/zzl/go-win32api/win32"
"github.com/zzl/go-win32api/v2/win32"
)

type IDataObjectImpl struct {
Expand Down Expand Up @@ -71,7 +71,7 @@ func (this *IDataObjectImpl) GetData(pformatetcIn *win32.FORMATETC, pmedium *win
bts := unsafe.Slice((*uint16)(unsafe.Pointer(h)), cb)
copy(bts, wsz)
*pmedium.HGlobal() = h
pmedium.Tymed = (uint32)(win32.TYMED_HGLOBAL)
pmedium.Tymed = win32.TYMED_HGLOBAL
}
}
} else if win32.SUCCEEDED(this.lazyLoadShellDo()) {
Expand Down Expand Up @@ -143,43 +143,46 @@ func (this *IDataObjectImpl) EnumDAdvise(ppenumAdvise **win32.IEnumSTATDATA) win
//
type IDataObjectComObj struct {
com.IUnknownComObj
impl win32.IDataObjectInterface
}

func (this *IDataObjectComObj) impl() win32.IDataObjectInterface {
return this.Impl().(win32.IDataObjectInterface)
}

func (this *IDataObjectComObj) GetData(pformatetcIn *win32.FORMATETC, pmedium *win32.STGMEDIUM) uintptr {
return uintptr(this.impl.GetData(pformatetcIn, pmedium))
return uintptr(this.impl().GetData(pformatetcIn, pmedium))
}

func (this *IDataObjectComObj) GetDataHere(pformatetc *win32.FORMATETC, pmedium *win32.STGMEDIUM) uintptr {
return uintptr(this.impl.GetDataHere(pformatetc, pmedium))
return uintptr(this.impl().GetDataHere(pformatetc, pmedium))
}

func (this *IDataObjectComObj) QueryGetData(pformatetc *win32.FORMATETC) uintptr {
return uintptr(this.impl.QueryGetData(pformatetc))
return uintptr(this.impl().QueryGetData(pformatetc))
}

func (this *IDataObjectComObj) GetCanonicalFormatEtc(pformatectIn *win32.FORMATETC, pformatetcOut *win32.FORMATETC) uintptr {
return uintptr(this.impl.GetCanonicalFormatEtc(pformatectIn, pformatetcOut))
return uintptr(this.impl().GetCanonicalFormatEtc(pformatectIn, pformatetcOut))
}

func (this *IDataObjectComObj) SetData(pformatetc *win32.FORMATETC, pmedium *win32.STGMEDIUM, fRelease win32.BOOL) uintptr {
return uintptr(this.impl.SetData(pformatetc, pmedium, fRelease))
return uintptr(this.impl().SetData(pformatetc, pmedium, fRelease))
}

func (this *IDataObjectComObj) EnumFormatEtc(dwDirection uint32, ppenumFormatEtc **win32.IEnumFORMATETC) uintptr {
return uintptr(this.impl.EnumFormatEtc(dwDirection, ppenumFormatEtc))
return uintptr(this.impl().EnumFormatEtc(dwDirection, ppenumFormatEtc))
}

func (this *IDataObjectComObj) DAdvise(pformatetc *win32.FORMATETC, advf uint32, pAdvSink *win32.IAdviseSink, pdwConnection *uint32) uintptr {
return uintptr(this.impl.DAdvise(pformatetc, advf, pAdvSink, pdwConnection))
return uintptr(this.impl().DAdvise(pformatetc, advf, pAdvSink, pdwConnection))
}

func (this *IDataObjectComObj) DUnadvise(dwConnection uint32) uintptr {
return uintptr(this.impl.DUnadvise(dwConnection))
return uintptr(this.impl().DUnadvise(dwConnection))
}

func (this *IDataObjectComObj) EnumDAdvise(ppenumAdvise **win32.IEnumSTATDATA) uintptr {
return uintptr(this.impl.EnumDAdvise(ppenumAdvise))
return uintptr(this.impl().EnumDAdvise(ppenumAdvise))
}

var _pIDataObjectVtbl *win32.IDataObjectVtbl
Expand Down Expand Up @@ -207,7 +210,19 @@ func (this *IDataObjectComObj) BuildVtbl(lock bool) *win32.IDataObjectVtbl {
return _pIDataObjectVtbl
}

func (this *IDataObjectComObj) GetVtbl() *win32.IUnknownVtbl {
return &this.BuildVtbl(true).IUnknownVtbl
}

func (this *IDataObjectComObj) IDataObject() *win32.IDataObject {
return (*win32.IDataObject)(unsafe.Pointer(this))
}

func NewIDataObjectComObj(impl win32.IDataObjectInterface) *IDataObjectComObj {
comObj := com.NewComObj[IDataObjectComObj](impl)
return comObj
}

func NewDataObject() *win32.IDataObject {
return NewIDataObjectComObj(&IDataObjectImpl{}).IDataObject()
}
28 changes: 22 additions & 6 deletions com/comimpl/IDropSource.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"unsafe"

"github.com/zzl/go-com/com"
"github.com/zzl/go-win32api/win32"
"github.com/zzl/go-win32api/v2/win32"
)

type IDropSourceImpl struct {
Expand All @@ -32,15 +32,18 @@ func (this *IDropSourceImpl) GiveFeedback(dwEffect uint32) win32.HRESULT {
//
type IDropSourceComObj struct {
com.IUnknownComObj
impl win32.IDropSourceInterface
}

func (this *IDropSourceComObj) QueryContinueDrag(fEscapePressed win32.BOOL, grfKeyState uint32) uintptr {
return uintptr(this.impl.QueryContinueDrag(fEscapePressed, grfKeyState))
func (this *IDropSourceComObj) impl() win32.IDropSourceInterface {
return this.Impl().(win32.IDropSourceInterface)
}

func (this *IDropSourceComObj) GiveFeedback(dwEffect uint32) uintptr {
return uintptr(this.impl.GiveFeedback(dwEffect))
func (this *IDropSourceComObj) QueryContinueDrag(fEscapePressed win32.BOOL, grfKeyState win32.MODIFIERKEYS_FLAGS) uintptr {
return uintptr(this.impl().QueryContinueDrag(fEscapePressed, grfKeyState))
}

func (this *IDropSourceComObj) GiveFeedback(dwEffect win32.DROPEFFECT) uintptr {
return uintptr(this.impl().GiveFeedback(dwEffect))
}

var _pIDropSourceVtbl *win32.IDropSourceVtbl
Expand All @@ -60,3 +63,16 @@ func (this *IDropSourceComObj) BuildVtbl(lock bool) *win32.IDropSourceVtbl {
}
return _pIDropSourceVtbl
}

func (this *IDropSourceComObj) GetVtbl() *win32.IUnknownVtbl {
return &this.BuildVtbl(true).IUnknownVtbl
}

func (this *IDropSourceComObj) IDropSource() *win32.IDropSource {
return (*win32.IDropSource)(unsafe.Pointer(this))
}

func NewIDropSourceComObj(impl win32.IDropSourceInterface) *IDropSourceComObj {
comObj := com.NewComObj[IDropSourceComObj](impl)
return comObj
}
37 changes: 28 additions & 9 deletions com/comimpl/IDropTarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"unsafe"

"github.com/zzl/go-com/com"
"github.com/zzl/go-win32api/win32"
"github.com/zzl/go-win32api/v2/win32"
)

type IDropTargetImpl struct {
Expand Down Expand Up @@ -40,23 +40,29 @@ func (this *IDropTargetImpl) Drop(pDataObj *win32.IDataObject, grfKeyState uint3
//
type IDropTargetComObj struct {
com.IUnknownComObj
impl win32.IDropTargetInterface
}

func (this *IDropTargetComObj) DragEnter(pDataObj *win32.IDataObject, grfKeyState uint32, pt win32.POINTL, pdwEffect *uint32) uintptr {
return uintptr(this.impl.DragEnter(pDataObj, grfKeyState, pt, pdwEffect))
func (this *IDropTargetComObj) impl() win32.IDropTargetInterface {
return this.Impl().(win32.IDropTargetInterface)
}

func (this *IDropTargetComObj) DragOver(grfKeyState uint32, pt win32.POINTL, pdwEffect *uint32) uintptr {
return uintptr(this.impl.DragOver(grfKeyState, pt, pdwEffect))
func (this *IDropTargetComObj) DragEnter(pDataObj *win32.IDataObject, grfKeyState win32.MODIFIERKEYS_FLAGS,
pt win32.POINTL, pdwEffect *win32.DROPEFFECT) uintptr {
return uintptr(this.impl().DragEnter(pDataObj, grfKeyState, pt, pdwEffect))
}

func (this *IDropTargetComObj) DragOver(grfKeyState win32.MODIFIERKEYS_FLAGS,
pt win32.POINTL, pdwEffect *win32.DROPEFFECT) uintptr {
return uintptr(this.impl().DragOver(grfKeyState, pt, pdwEffect))
}

func (this *IDropTargetComObj) DragLeave() uintptr {
return uintptr(this.impl.DragLeave())
return uintptr(this.impl().DragLeave())
}

func (this *IDropTargetComObj) Drop(pDataObj *win32.IDataObject, grfKeyState uint32, pt win32.POINTL, pdwEffect *uint32) uintptr {
return uintptr(this.impl.Drop(pDataObj, grfKeyState, pt, pdwEffect))
func (this *IDropTargetComObj) Drop(pDataObj *win32.IDataObject, grfKeyState win32.MODIFIERKEYS_FLAGS,
pt win32.POINTL, pdwEffect *win32.DROPEFFECT) uintptr {
return uintptr(this.impl().Drop(pDataObj, grfKeyState, pt, pdwEffect))
}

var _pIDropTargetVtbl *win32.IDropTargetVtbl
Expand All @@ -78,3 +84,16 @@ func (this *IDropTargetComObj) BuildVtbl(lock bool) *win32.IDropTargetVtbl {
}
return _pIDropTargetVtbl
}

func (this *IDropTargetComObj) GetVtbl() *win32.IUnknownVtbl {
return &this.BuildVtbl(true).IUnknownVtbl
}

func (this *IDropTargetComObj) IDropTarget() *win32.IDropTarget {
return (*win32.IDropTarget)(unsafe.Pointer(this))
}

func NewIDropTargetComObj(impl win32.IDropTargetInterface) *IDropTargetComObj {
comObj := com.NewComObj[IDropTargetComObj](impl)
return comObj
}
2 changes: 1 addition & 1 deletion com/comimpl/IPropertyBag.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package comimpl

import (
"github.com/zzl/go-com/com"
"github.com/zzl/go-win32api/win32"
"github.com/zzl/go-win32api/v2/win32"
"syscall"
"unsafe"
)
Expand Down
2 changes: 1 addition & 1 deletion com/comimpl/ISequentialStream.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"unsafe"

"github.com/zzl/go-com/com"
"github.com/zzl/go-win32api/win32"
"github.com/zzl/go-win32api/v2/win32"
)

//
Expand Down
10 changes: 5 additions & 5 deletions com/comimpl/IStream.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"unsafe"

"github.com/zzl/go-com/com"
"github.com/zzl/go-win32api/win32"
"github.com/zzl/go-win32api/v2/win32"
)

//
Expand Down Expand Up @@ -43,15 +43,15 @@ func (this *IStreamImpl) Revert() win32.HRESULT {
return win32.E_NOTIMPL
}

func (this *IStreamImpl) LockRegion(libOffset uint64, cb uint64, dwLockType uint32) win32.HRESULT {
func (this *IStreamImpl) LockRegion(libOffset uint64, cb uint64, dwLockType win32.LOCKTYPE) win32.HRESULT {
return win32.E_NOTIMPL
}

func (this *IStreamImpl) UnlockRegion(libOffset uint64, cb uint64, dwLockType uint32) win32.HRESULT {
return win32.E_NOTIMPL
}

func (this *IStreamImpl) Stat(pstatstg *win32.STATSTG, grfStatFlag uint32) win32.HRESULT {
func (this *IStreamImpl) Stat(pstatstg *win32.STATSTG, grfStatFlag win32.STATFLAG) win32.HRESULT {
return win32.E_NOTIMPL
}

Expand Down Expand Up @@ -96,15 +96,15 @@ func (this *IStreamComObj) Revert() uintptr {
return (uintptr)(this.impl().Revert())
}

func (this *IStreamComObj) LockRegion(libOffset uint64, cb uint64, dwLockType uint32) uintptr {
func (this *IStreamComObj) LockRegion(libOffset uint64, cb uint64, dwLockType win32.LOCKTYPE) uintptr {
return (uintptr)(this.impl().LockRegion(libOffset, cb, dwLockType))
}

func (this *IStreamComObj) UnlockRegion(libOffset uint64, cb uint64, dwLockType uint32) uintptr {
return (uintptr)(this.impl().UnlockRegion(libOffset, cb, dwLockType))
}

func (this *IStreamComObj) Stat(pstatstg *win32.STATSTG, grfStatFlag uint32) uintptr {
func (this *IStreamComObj) Stat(pstatstg *win32.STATSTG, grfStatFlag win32.STATFLAG) uintptr {
return (uintptr)(this.impl().Stat(pstatstg, grfStatFlag))
}

Expand Down
2 changes: 1 addition & 1 deletion com/context.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com

import (
"github.com/zzl/go-win32api/win32"
"github.com/zzl/go-win32api/v2/win32"
"log"
"runtime"
"sync"
Expand Down
2 changes: 1 addition & 1 deletion com/error.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com

import (
"github.com/zzl/go-win32api/win32"
"github.com/zzl/go-win32api/v2/win32"
"syscall"
)

Expand Down
2 changes: 1 addition & 1 deletion com/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"syscall"
"unsafe"

"github.com/zzl/go-win32api/win32"
"github.com/zzl/go-win32api/v2/win32"
)

var MuVtbl sync.Mutex
Expand Down
2 changes: 1 addition & 1 deletion com/scope.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com

import (
"github.com/zzl/go-win32api/win32"
"github.com/zzl/go-win32api/v2/win32"
"log"
"sync"
"unsafe"
Expand Down
2 changes: 1 addition & 1 deletion com/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"syscall"
"unsafe"

"github.com/zzl/go-win32api/win32"
"github.com/zzl/go-win32api/v2/win32"
)

type Disposable interface {
Expand Down
2 changes: 1 addition & 1 deletion com/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com

import (
"fmt"
"github.com/zzl/go-win32api/win32"
"github.com/zzl/go-win32api/v2/win32"
"log"
"unsafe"
)
Expand Down
2 changes: 1 addition & 1 deletion examples/filedialog/filedialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"unsafe"

"github.com/zzl/go-com/com"
"github.com/zzl/go-win32api/win32"
"github.com/zzl/go-win32api/v2/win32"
)

type IFileDialogEventsInterfaceImpl struct {
Expand Down
2 changes: 1 addition & 1 deletion examples/loadpicture_fromstream/loadpicture_fromstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/zzl/go-com/com/comimpl"
"github.com/zzl/go-com/ole"
"github.com/zzl/go-win32api/win32"
"github.com/zzl/go-win32api/v2/win32"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/zzl/go-com

go 1.18
go 1.19

require github.com/zzl/go-win32api v1.2.0
require github.com/zzl/go-win32api/v2 v2.0.1

require golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f // indirect
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github.com/zzl/go-win32api v1.2.0 h1:8cUPn/io9S0H/Ah4pnuM7xmElL2MDR9bKgl8AREG/AE=
github.com/zzl/go-win32api v1.2.0/go.mod h1:iWVjU/KzuwzqGpgBZdQ6Z4JqFXeSPIzantVIkcyD4b4=
github.com/zzl/go-win32api/v2 v2.0.1 h1:SHeKZMcYqQNIxbZefuUffM3K+YuJ/WMhd8ZHr40M0OM=
github.com/zzl/go-win32api/v2 v2.0.1/go.mod h1:doi6ewHPdh9tDmqe837Ro7IwqtB9yE+1fC8suK/Ssj0=
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f h1:rlezHXNlxYWvBCzNses9Dlc7nGFaNMJeqLolcmQSSZY=
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Loading

0 comments on commit 51c6c3f

Please sign in to comment.