summaryrefslogtreecommitdiff
path: root/new/ids.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-04-15 18:51:41 -0400
committerPietro Gagliardi <[email protected]>2015-04-15 18:51:41 -0400
commit30ea82d08de439ca52f52e93b6409df1ccd73fc0 (patch)
treed74bb38271cd83fc0793ae61c62e0145779e67af /new/ids.go
parent823397cf5526a61d6b3a19bb16ab0b2c3da7f95e (diff)
Removed ids.go. It can be recreated later.
Diffstat (limited to 'new/ids.go')
-rw-r--r--new/ids.go61
1 files changed, 0 insertions, 61 deletions
diff --git a/new/ids.go b/new/ids.go
deleted file mode 100644
index 66dd587..0000000
--- a/new/ids.go
+++ /dev/null
@@ -1,61 +0,0 @@
-// 23 february 2015
-
-package ui
-
-// Go pointers cannot be passed to C safely.
-// The Go runtime will move them around, tripping C up.
-// However, C pointers don't have this problem.
-// Solution: use the C pointer to get the Go object needed!
-
-import (
- "fmt"
- "sync"
-)
-
-var (
- ids map[uintptr]interface{}
- idsLock sync.Mutex
-)
-
-func getGoObject(cptr uintptr) interface{} {
- idsLock.Lock()
- defer idsLock.Unlock()
-
- if i, ok := ids[cptr]; ok {
- return i
- }
- panic(fmt.Errorf("[BUG in package ui; report to andlabs immediately] C pointer %p not associated with Go object in package ui", cptr))
-}
-
-func associateGoObject(cptr uintptr, goobj interface{}) {
- idsLock.Lock()
- defer idsLock.Unlock()
-
- if i, ok := ids[cptr]; ok {
- panic(fmt.Errorf("[BUG in package ui; report to andlabs immediately] C pointer %p already associated with Go object of type %T but we want to associate it with Go object of type %T", cptr, i, goobj))
- }
- ids[cptr] = goobj
-}
-
-func disassociateGoObject(cptr uintptr) {
- idsLock.Lock()
- defer idsLock.Unlock()
-
- if _, ok := ids[cptr]; !ok {
- panic(fmt.Errorf("[BUG in package ui; report to andlabs immediately] C pointer %p not associated with any Go object but we want to disassociate it", cptr))
- }
- delete(ids, cptr)
-}
-
-func idsHandler(req *request) bool {
- switch req.id {
- case reqObjectDestroyed:
- disassociateGoObject(req.ptr)
- return true
- }
- return false
-}
-
-func init() {
- interopHandlers = append(interopHandlers, idsHandler)
-}