github.com/provpn/mobile@v0.0.0-20210315122651-28c475f89f6c/bind/objc/ref.h (about) 1 // Copyright 2015 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 #ifndef __GO_REF_HDR__ 6 #define __GO_REF_HDR__ 7 8 #include <Foundation/Foundation.h> 9 10 // GoSeqRef is an object tagged with an integer for passing back and 11 // forth across the language boundary. A GoSeqRef may represent either 12 // an instance of a Go object, or an Objective-C object passed to Go. 13 // The explicit allocation of a GoSeqRef is used to pin a Go object 14 // when it is passed to Objective-C. The Go seq package maintains a 15 // reference to the Go object in a map keyed by the refnum along with 16 // a reference count. When the reference count reaches zero, the Go 17 // seq package will clear the corresponding entry in the map. 18 @interface GoSeqRef : NSObject { 19 } 20 @property(readonly) int32_t refnum; 21 @property(strong) id obj; // NULL when representing a Go object. 22 23 // new GoSeqRef object to proxy a Go object. The refnum must be 24 // provided from Go side. 25 - (instancetype)initWithRefnum:(int32_t)refnum obj:(id)obj; 26 27 - (int32_t)incNum; 28 29 @end 30 31 @protocol goSeqRefInterface 32 -(GoSeqRef*) _ref; 33 @end 34 35 #endif