Skip to content

Commit

Permalink
Convert uintptr to Pointer in one line
Browse files Browse the repository at this point in the history
It's invalid using of converting uintptr to unsafe.Pointer
except do this in one line.

See also:  https://golang.org/pkg/unsafe/ (3)

Change-Id: I15a3b056dda660a2f00bce7a7d80bf16f2e917a5
  • Loading branch information
snyh committed Oct 12, 2016
1 parent 18bc037 commit ae0c286
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/gir-generator/templates.go
Expand Up @@ -149,8 +149,8 @@ func To[<.name>](objlike [<.gobjectns>]ObjectLike) *[<.name>] {
}
func (this0 *[<.name>]Impl) Implements[<.cprefix>][<.name>]() [<.cgotype>] {
obj := uintptr(unsafe.Pointer(this0)) - unsafe.Sizeof(uintptr(0))
return ([<.cgotype>])((*[<.gobjectns>]Object)(unsafe.Pointer(obj)).C)
base := unsafe.Pointer(uintptr(unsafe.Pointer(this0)) - unsafe.Sizeof(uintptr(0)))
return ([<.cgotype>])((*[<.gobjectns>]Object)(base).C)
}
`)
Expand Down

0 comments on commit ae0c286

Please sign in to comment.