// 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 "GoIssue12403.h"

static NSString* errDomain = @"go.issue12403";

@implementation GoIssue12403Parsable {
}

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

- (NSString*)fromJSON:(NSString*)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_;
}

- (BOOL)toJSON:(NSString**)ret0_ error:(NSError**)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);
	NSString *_error = go_seq_to_objc_string(res.r1);
	*ret0_ = _ret0_;
	if ([_error length] != 0 && error != nil) {
		NSMutableDictionary* details = [NSMutableDictionary dictionary];
		[details setValue:_error forKey:NSLocalizedDescriptionKey];
		*error = [NSError errorWithDomain:errDomain code:1 userInfo:details];
	}
	return ([_error length] == 0);
}

@end



nstring cproxyissue12403_Parsable_FromJSON(int32_t refnum, nstring jstr) {
	@autoreleasepool {
		id<GoIssue12403Parsable> o = go_seq_objc_from_refnum(refnum);
		NSString *_jstr = go_seq_to_objc_string(jstr);
		NSString* returnVal = [o fromJSON:_jstr];
		nstring _returnVal = go_seq_from_objc_string(returnVal);
		return _returnVal;
	}
}

struct cproxyissue12403_Parsable_ToJSON_return cproxyissue12403_Parsable_ToJSON(int32_t refnum) {
	@autoreleasepool {
		id<GoIssue12403Parsable> o = go_seq_objc_from_refnum(refnum);
		NSString* ret0_;
		NSError* error = nil;
		BOOL returnVal = [o toJSON:&ret0_ error:&error];
		nstring _ret0_ = go_seq_from_objc_string(ret0_);
		NSString *error_str = nil;
		if (!returnVal) {
			error_str = [error localizedDescription];
			if (error_str == nil || error_str.length == 0) {
				error_str = @"gobind: unknown error";
			}
		}
		nstring _error_str = go_seq_from_objc_string(error_str);
		cproxyissue12403_Parsable_ToJSON_return _sres = {
		  _ret0_, _error_str
		};
		return _sres;
	}
}

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