structs.objc.m.golden 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. // Objective-C API for talking to structs Go package.
  2. // gobind -lang=objc structs
  3. //
  4. // File is generated by gobind. Do not edit.
  5. #include <Foundation/Foundation.h>
  6. #include "seq.h"
  7. #include "_cgo_export.h"
  8. #include "Structs.objc.h"
  9. @implementation StructsS {
  10. }
  11. - (nonnull instancetype)initWithRef:(_Nonnull id)ref {
  12. self = [super init];
  13. if (self) { __ref = ref; }
  14. return self;
  15. }
  16. - (nonnull instancetype)init {
  17. self = [super init];
  18. if (self) {
  19. __ref = go_seq_from_refnum(new_structs_S());
  20. }
  21. return self;
  22. }
  23. - (double)x {
  24. int32_t refnum = go_seq_go_to_refnum(self._ref);
  25. double r0 = proxystructs_S_X_Get(refnum);
  26. double _r0 = (double)r0;
  27. return _r0;
  28. }
  29. - (void)setX:(double)v {
  30. int32_t refnum = go_seq_go_to_refnum(self._ref);
  31. double _v = (double)v;
  32. proxystructs_S_X_Set(refnum, _v);
  33. }
  34. - (double)y {
  35. int32_t refnum = go_seq_go_to_refnum(self._ref);
  36. double r0 = proxystructs_S_Y_Get(refnum);
  37. double _r0 = (double)r0;
  38. return _r0;
  39. }
  40. - (void)setY:(double)v {
  41. int32_t refnum = go_seq_go_to_refnum(self._ref);
  42. double _v = (double)v;
  43. proxystructs_S_Y_Set(refnum, _v);
  44. }
  45. - (StructsS* _Nullable)identity:(NSError* _Nullable* _Nullable)error {
  46. int32_t refnum = go_seq_go_to_refnum(self._ref);
  47. struct proxystructs_S_Identity_return res = proxystructs_S_Identity(refnum);
  48. StructsS* _ret0_ = nil;
  49. GoSeqRef* _ret0__ref = go_seq_from_refnum(res.r0);
  50. if (_ret0__ref != NULL) {
  51. _ret0_ = _ret0__ref.obj;
  52. if (_ret0_ == nil) {
  53. _ret0_ = [[StructsS alloc] initWithRef:_ret0__ref];
  54. }
  55. }
  56. Universeerror* _error = nil;
  57. GoSeqRef* _error_ref = go_seq_from_refnum(res.r1);
  58. if (_error_ref != NULL) {
  59. _error = _error_ref.obj;
  60. if (_error == nil) {
  61. _error = [[Universeerror alloc] initWithRef:_error_ref];
  62. }
  63. }
  64. if (_error != nil && error != nil) {
  65. *error = _error;
  66. }
  67. if (_error != nil) {
  68. return nil;
  69. }
  70. return _ret0_;
  71. }
  72. - (double)sum {
  73. int32_t refnum = go_seq_go_to_refnum(self._ref);
  74. double r0 = proxystructs_S_Sum(refnum);
  75. double _ret0_ = (double)r0;
  76. return _ret0_;
  77. }
  78. @end
  79. @implementation StructsS2 {
  80. }
  81. - (nonnull instancetype)initWithRef:(_Nonnull id)ref {
  82. self = [super init];
  83. if (self) { __ref = ref; }
  84. return self;
  85. }
  86. - (nonnull instancetype)init {
  87. self = [super init];
  88. if (self) {
  89. __ref = go_seq_from_refnum(new_structs_S2());
  90. }
  91. return self;
  92. }
  93. - (void)m {
  94. int32_t refnum = go_seq_go_to_refnum(self._ref);
  95. proxystructs_S2_M(refnum);
  96. }
  97. - (NSString* _Nonnull)string {
  98. int32_t refnum = go_seq_go_to_refnum(self._ref);
  99. nstring r0 = proxystructs_S2_String(refnum);
  100. NSString *_ret0_ = go_seq_to_objc_string(r0);
  101. return _ret0_;
  102. }
  103. @end
  104. @implementation StructsStructs {
  105. }
  106. - (nonnull instancetype)initWithRef:(_Nonnull id)ref {
  107. self = [super init];
  108. if (self) { __ref = ref; }
  109. return self;
  110. }
  111. - (nonnull instancetype)init {
  112. self = [super init];
  113. if (self) {
  114. __ref = go_seq_from_refnum(new_structs_Structs());
  115. }
  116. return self;
  117. }
  118. - (void)m {
  119. int32_t refnum = go_seq_go_to_refnum(self._ref);
  120. proxystructs_Structs_M(refnum);
  121. }
  122. @end
  123. @implementation StructsI {
  124. }
  125. - (nonnull instancetype)initWithRef:(id)ref {
  126. self = [super init];
  127. if (self) { __ref = ref; }
  128. return self;
  129. }
  130. - (void)m {
  131. int32_t refnum = go_seq_go_to_refnum(self._ref);
  132. proxystructs_I_M(refnum);
  133. }
  134. @end
  135. StructsS* _Nullable StructsIdentity(StructsS* _Nullable s) {
  136. int32_t _s;
  137. if ([s conformsToProtocol:@protocol(goSeqRefInterface)]) {
  138. id<goSeqRefInterface> s_proxy = (id<goSeqRefInterface>)(s);
  139. _s = go_seq_go_to_refnum(s_proxy._ref);
  140. } else {
  141. _s = go_seq_to_refnum(s);
  142. }
  143. int32_t r0 = proxystructs__Identity(_s);
  144. StructsS* _ret0_ = nil;
  145. GoSeqRef* _ret0__ref = go_seq_from_refnum(r0);
  146. if (_ret0__ref != NULL) {
  147. _ret0_ = _ret0__ref.obj;
  148. if (_ret0_ == nil) {
  149. _ret0_ = [[StructsS alloc] initWithRef:_ret0__ref];
  150. }
  151. }
  152. return _ret0_;
  153. }
  154. StructsS* _Nullable StructsIdentityWithError(StructsS* _Nullable s, NSError* _Nullable* _Nullable error) {
  155. int32_t _s;
  156. if ([s conformsToProtocol:@protocol(goSeqRefInterface)]) {
  157. id<goSeqRefInterface> s_proxy = (id<goSeqRefInterface>)(s);
  158. _s = go_seq_go_to_refnum(s_proxy._ref);
  159. } else {
  160. _s = go_seq_to_refnum(s);
  161. }
  162. struct proxystructs__IdentityWithError_return res = proxystructs__IdentityWithError(_s);
  163. StructsS* _ret0_ = nil;
  164. GoSeqRef* _ret0__ref = go_seq_from_refnum(res.r0);
  165. if (_ret0__ref != NULL) {
  166. _ret0_ = _ret0__ref.obj;
  167. if (_ret0_ == nil) {
  168. _ret0_ = [[StructsS alloc] initWithRef:_ret0__ref];
  169. }
  170. }
  171. Universeerror* _error = nil;
  172. GoSeqRef* _error_ref = go_seq_from_refnum(res.r1);
  173. if (_error_ref != NULL) {
  174. _error = _error_ref.obj;
  175. if (_error == nil) {
  176. _error = [[Universeerror alloc] initWithRef:_error_ref];
  177. }
  178. }
  179. if (_error != nil && error != nil) {
  180. *error = _error;
  181. }
  182. if (_error != nil) {
  183. return nil;
  184. }
  185. return _ret0_;
  186. }
  187. void cproxystructs_I_M(int32_t refnum) {
  188. @autoreleasepool {
  189. StructsI* o = go_seq_objc_from_refnum(refnum);
  190. [o m];
  191. }
  192. }
  193. __attribute__((constructor)) static void init() {
  194. init_seq();
  195. }