// Objective-C API for talking to issue12403 Go package.
//   gobind -lang=objc issue12403
//
// File is generated by gobind. Do not edit.

#include <Foundation/Foundation.h>
#include "seq.h"
#include "_cgo_export.h"
#include "Issue12403.objc.h"

@implementation Issue12403Parsable {
}

- (nonnull instancetype)initWithRef:(id)ref {
	self = [super init];
	if (self) { __ref = ref; }
	return self;
}

- (NSString* _Nonnull)fromJSON:(NSString* _Nullable)jstr {
	int32_t refnum = go_seq_go_to_refnum(self._ref);
	nstring _jstr = go_seq_from_objc_string(jstr);
	nstring r0 = proxyissue12403_Parsable_FromJSON(refnum, _jstr);
	NSString *_ret0_ = go_seq_to_objc_string(r0);
	return _ret0_;
}

- (NSString* _Nonnull)toJSON:(NSError* _Nullable* _Nullable)error {
	int32_t refnum = go_seq_go_to_refnum(self._ref);
	struct proxyissue12403_Parsable_ToJSON_return res = proxyissue12403_Parsable_ToJSON(refnum);
	NSString *_ret0_ = go_seq_to_objc_string(res.r0);
	Universeerror* _error = nil;
	GoSeqRef* _error_ref = go_seq_from_refnum(res.r1);
	if (_error_ref != NULL) {
		_error = _error_ref.obj;
		if (_error == nil) {
			_error = [[Universeerror alloc] initWithRef:_error_ref];
		}
	}
	if (_error != nil && error != nil) {
		*error = _error;
	}
	if (_error != nil) {
		return nil;
	}
	return _ret0_;
}

@end



nstring cproxyissue12403_Parsable_FromJSON(int32_t refnum, nstring jstr) {
	@autoreleasepool {
		Issue12403Parsable* o = go_seq_objc_from_refnum(refnum);
		NSString *_jstr = go_seq_to_objc_string(jstr);
		NSString* _Nonnull ret0_;
		ret0_ = [o fromJSON:_jstr];
		nstring _ret0_ = go_seq_from_objc_string(ret0_);
		return _ret0_;
	}
}

struct cproxyissue12403_Parsable_ToJSON_return cproxyissue12403_Parsable_ToJSON(int32_t refnum) {
	@autoreleasepool {
		Issue12403Parsable* o = go_seq_objc_from_refnum(refnum);
		NSString* _Nonnull ret0_;
		NSError* error = nil;
		ret0_ = [o toJSON:&error];
		nstring _ret0_ = go_seq_from_objc_string(ret0_);
		NSError *_error = nil;
		if (error != nil) {
			_error = error;
		}
		int32_t __error;
		if ([_error conformsToProtocol:@protocol(goSeqRefInterface)]) {
			id<goSeqRefInterface> _error_proxy = (id<goSeqRefInterface>)(_error);
			__error = go_seq_go_to_refnum(_error_proxy._ref);
		} else {
			__error = go_seq_to_refnum(_error);
		}
		cproxyissue12403_Parsable_ToJSON_return _sres = {
		  _ret0_, __error
		};
		return _sres;
	}
}

__attribute__((constructor)) static void init() {
	init_seq();
}
