github.com/danbrough/mobile@v0.0.3-beta03/bind/seq.go.support (about) 1 // Copyright 2016 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 // Go support functions for generated Go bindings. This file is 8 // copied into the generated main package, and compiled along 9 // with the bindings. 10 11 // #cgo android CFLAGS: -D__GOBIND_ANDROID__ 12 // #cgo windows CFLAGS: -D__GOBIND_LINUX__ -D__GOBIND_WINDOWS__ 13 // #cgo linux CFLAGS: -D__GOBIND_LINUX__ 14 // #cgo darwin CFLAGS: -D__GOBIND_DARWIN__ 15 // #include <stdlib.h> 16 // #include "seq.h" 17 import "C" 18 19 import ( 20 "fmt" 21 "os" 22 "os/signal" 23 "syscall" 24 25 _ "github.com/danbrough/mobile/bind/java" 26 _seq "github.com/danbrough/mobile/bind/seq" 27 ) 28 29 func init() { 30 _seq.FinalizeRef = func(ref *_seq.Ref) { 31 refnum := ref.Bind_Num 32 if refnum < 0 { 33 panic(fmt.Sprintf("not a foreign ref: %d", refnum)) 34 } 35 C.go_seq_dec_ref(C.int32_t(refnum)) 36 } 37 _seq.IncForeignRef = func(refnum int32) { 38 if refnum < 0 { 39 panic(fmt.Sprintf("not a foreign ref: %d", refnum)) 40 } 41 C.go_seq_inc_ref(C.int32_t(refnum)) 42 } 43 // Workaround for issue #17393. 44 signal.Notify(make(chan os.Signal), syscall.SIGPIPE) 45 } 46 47 // IncGoRef is called by foreign code to pin a Go object while its refnum is crossing 48 // the language barrier 49 //export IncGoRef 50 func IncGoRef(refnum C.int32_t) { 51 _seq.Inc(int32(refnum)) 52 } 53 54 func main() {}