ref.h 1.1 KB

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