37 lines
729 B
Plaintext
37 lines
729 B
Plaintext
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||
|
// Use of this source code is governed by a BSD-style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
|
package gomobile_bind
|
||
|
|
||
|
// Go support functions for generated Go bindings. This file is
|
||
|
// copied into the generated package, gomobile_bind, and compiled
|
||
|
// along with the bindings.
|
||
|
|
||
|
// #include <stdlib.h>
|
||
|
// #include "seq.h"
|
||
|
import "C"
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"fmt"
|
||
|
|
||
|
_seq "golang.org/x/mobile/bind/seq"
|
||
|
)
|
||
|
|
||
|
func toError(s string) error {
|
||
|
if s == "" {
|
||
|
return nil
|
||
|
}
|
||
|
return errors.New(s)
|
||
|
}
|
||
|
|
||
|
func init() {
|
||
|
_seq.FinalizeRef = func(ref *_seq.Ref) {
|
||
|
if ref.Num < 0 {
|
||
|
panic(fmt.Sprintf("not a foreign ref: %d", ref.Num))
|
||
|
}
|
||
|
C.go_seq_dec_ref(C.int32_t(ref.Num))
|
||
|
}
|
||
|
}
|