issue12403.objc.m.golden 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // Objective-C API for talking to issue12403 Go package.
  2. // gobind -lang=objc issue12403
  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 "Issue12403.objc.h"
  9. @implementation Issue12403Parsable {
  10. }
  11. - (nonnull instancetype)initWithRef:(id)ref {
  12. self = [super init];
  13. if (self) { __ref = ref; }
  14. return self;
  15. }
  16. - (NSString* _Nonnull)fromJSON:(NSString* _Nullable)jstr {
  17. int32_t refnum = go_seq_go_to_refnum(self._ref);
  18. nstring _jstr = go_seq_from_objc_string(jstr);
  19. nstring r0 = proxyissue12403_Parsable_FromJSON(refnum, _jstr);
  20. NSString *_ret0_ = go_seq_to_objc_string(r0);
  21. return _ret0_;
  22. }
  23. - (NSString* _Nonnull)toJSON:(NSError* _Nullable* _Nullable)error {
  24. int32_t refnum = go_seq_go_to_refnum(self._ref);
  25. struct proxyissue12403_Parsable_ToJSON_return res = proxyissue12403_Parsable_ToJSON(refnum);
  26. NSString *_ret0_ = go_seq_to_objc_string(res.r0);
  27. Universeerror* _error = nil;
  28. GoSeqRef* _error_ref = go_seq_from_refnum(res.r1);
  29. if (_error_ref != NULL) {
  30. _error = _error_ref.obj;
  31. if (_error == nil) {
  32. _error = [[Universeerror alloc] initWithRef:_error_ref];
  33. }
  34. }
  35. if (_error != nil && error != nil) {
  36. *error = _error;
  37. }
  38. if (_error != nil) {
  39. return nil;
  40. }
  41. return _ret0_;
  42. }
  43. @end
  44. nstring cproxyissue12403_Parsable_FromJSON(int32_t refnum, nstring jstr) {
  45. @autoreleasepool {
  46. Issue12403Parsable* o = go_seq_objc_from_refnum(refnum);
  47. NSString *_jstr = go_seq_to_objc_string(jstr);
  48. NSString* _Nonnull ret0_;
  49. ret0_ = [o fromJSON:_jstr];
  50. nstring _ret0_ = go_seq_from_objc_string(ret0_);
  51. return _ret0_;
  52. }
  53. }
  54. struct cproxyissue12403_Parsable_ToJSON_return cproxyissue12403_Parsable_ToJSON(int32_t refnum) {
  55. @autoreleasepool {
  56. Issue12403Parsable* o = go_seq_objc_from_refnum(refnum);
  57. NSString* _Nonnull ret0_;
  58. NSError* error = nil;
  59. ret0_ = [o toJSON:&error];
  60. nstring _ret0_ = go_seq_from_objc_string(ret0_);
  61. NSError *_error = nil;
  62. if (error != nil) {
  63. _error = error;
  64. }
  65. int32_t __error;
  66. if ([_error conformsToProtocol:@protocol(goSeqRefInterface)]) {
  67. id<goSeqRefInterface> _error_proxy = (id<goSeqRefInterface>)(_error);
  68. __error = go_seq_go_to_refnum(_error_proxy._ref);
  69. } else {
  70. __error = go_seq_to_refnum(_error);
  71. }
  72. cproxyissue12403_Parsable_ToJSON_return _sres = {
  73. _ret0_, __error
  74. };
  75. return _sres;
  76. }
  77. }
  78. __attribute__((constructor)) static void init() {
  79. init_seq();
  80. }