diff --git a/bind/genobjc.go b/bind/genobjc.go index cff4d4a..50c4a9f 100644 --- a/bind/genobjc.go +++ b/bind/genobjc.go @@ -254,7 +254,7 @@ func (s *funcSummary) asMethod(g *objcGen) string { if len(params) > 0 || i > 0 { key = p.name } - params = append(params, fmt.Sprintf("%s:(%s)%s", key, g.objcType(p.typ), p.name)) + params = append(params, fmt.Sprintf("%s:(%s)%s", key, g.objcType(p.typ)+"*", p.name)) } return fmt.Sprintf("(%s)%s%s", s.ret, s.name, strings.Join(params, " ")) } diff --git a/bind/testdata/structs.go b/bind/testdata/structs.go index 7218ce0..9b493ff 100644 --- a/bind/testdata/structs.go +++ b/bind/testdata/structs.go @@ -13,6 +13,10 @@ func (s *S) Sum() float64 { return s.X + s.Y } +func (s *S) Identity() (*S, error) { + return s, nil +} + func Identity(s *S) *S { return s } diff --git a/bind/testdata/structs.go.golden b/bind/testdata/structs.go.golden index f55b3e1..0fb4cff 100644 --- a/bind/testdata/structs.go.golden +++ b/bind/testdata/structs.go.golden @@ -31,12 +31,13 @@ func proxy_IdentityWithError(out, in *seq.Buffer) { } const ( - proxyS_Descriptor = "go.structs.S" - proxyS_X_Get_Code = 0x00f - proxyS_X_Set_Code = 0x01f - proxyS_Y_Get_Code = 0x10f - proxyS_Y_Set_Code = 0x11f - proxyS_Sum_Code = 0x00c + proxyS_Descriptor = "go.structs.S" + proxyS_X_Get_Code = 0x00f + proxyS_X_Set_Code = 0x01f + proxyS_Y_Get_Code = 0x10f + proxyS_Y_Set_Code = 0x11f + proxyS_Identity_Code = 0x00c + proxyS_Sum_Code = 0x10c ) type proxyS seq.Ref @@ -65,6 +66,18 @@ func proxyS_Y_Get(out, in *seq.Buffer) { out.WriteFloat64(v) } +func proxyS_Identity(out, in *seq.Buffer) { + ref := in.ReadRef() + v := ref.Get().(*structs.S) + res, err := v.Identity() + out.WriteGoRef(res) + if err == nil { + out.WriteString("") + } else { + out.WriteString(err.Error()) + } +} + func proxyS_Sum(out, in *seq.Buffer) { ref := in.ReadRef() v := ref.Get().(*structs.S) @@ -77,6 +90,7 @@ func init() { seq.Register(proxyS_Descriptor, proxyS_X_Get_Code, proxyS_X_Get) seq.Register(proxyS_Descriptor, proxyS_Y_Set_Code, proxyS_Y_Set) seq.Register(proxyS_Descriptor, proxyS_Y_Get_Code, proxyS_Y_Get) + seq.Register(proxyS_Descriptor, proxyS_Identity_Code, proxyS_Identity) seq.Register(proxyS_Descriptor, proxyS_Sum_Code, proxyS_Sum) } diff --git a/bind/testdata/structs.java.golden b/bind/testdata/structs.java.golden index f1f8a1e..52aaa74 100644 --- a/bind/testdata/structs.java.golden +++ b/bind/testdata/structs.java.golden @@ -39,7 +39,8 @@ public abstract class Structs { private static final int FIELD_X_SET = 0x01f; private static final int FIELD_Y_GET = 0x10f; private static final int FIELD_Y_SET = 0x11f; - private static final int CALL_Sum = 0x00c; + private static final int CALL_Identity = 0x00c; + private static final int CALL_Sum = 0x10c; private go.Seq.Ref ref; @@ -83,6 +84,20 @@ public abstract class Structs { Seq.send(DESCRIPTOR, FIELD_Y_SET, in, out); } + public S Identity() throws Exception { + go.Seq _in = new go.Seq(); + go.Seq _out = new go.Seq(); + S _result; + _in.writeRef(ref); + Seq.send(DESCRIPTOR, CALL_Identity, _in, _out); + _result = new S(_out.readRef()); + String _err = _out.readString(); + if (_err != null) { + throw new Exception(_err); + } + return _result; + } + public double Sum() { go.Seq _in = new go.Seq(); go.Seq _out = new go.Seq(); diff --git a/bind/testdata/structs.objc.h.golden b/bind/testdata/structs.objc.h.golden index 1a5b4bb..ec4c5d4 100644 --- a/bind/testdata/structs.objc.h.golden +++ b/bind/testdata/structs.objc.h.golden @@ -19,6 +19,7 @@ - (void)setX:(double)v; - (double)Y; - (void)setY:(double)v; +- (BOOL)Identity:(GoStructs_S**)ret0_ error:(NSError**)error; - (double)Sum; @end diff --git a/bind/testdata/structs.objc.m.golden b/bind/testdata/structs.objc.m.golden index 91e329a..354efe3 100644 --- a/bind/testdata/structs.objc.m.golden +++ b/bind/testdata/structs.objc.m.golden @@ -19,7 +19,8 @@ static NSString *errDomain = @"go.structs"; #define _GO_structs_S_FIELD_X_SET_ (0x01f) #define _GO_structs_S_FIELD_Y_GET_ (0x10f) #define _GO_structs_S_FIELD_Y_SET_ (0x11f) -#define _GO_structs_S_Sum_ (0x00c) +#define _GO_structs_S_Identity_ (0x00c) +#define _GO_structs_S_Sum_ (0x10c) @implementation GoStructs_S { } @@ -72,6 +73,29 @@ static NSString *errDomain = @"go.structs"; go_seq_free(&out_); } +- (BOOL)Identity:(GoStructs_S**)ret0_ error:(NSError**)error { + GoSeq in_ = {}; + GoSeq out_ = {}; + go_seq_writeRef(&in_, self.ref); + go_seq_send(_GO_structs_S_DESCRIPTOR_, _GO_structs_S_Identity_, &in_, &out_); + GoSeqRef* ret0__ref = go_seq_readRef(&out_); + if (ret0_ != NULL) { + *ret0_ = ret0__ref.obj; + if (*ret0_ == NULL) { + *ret0_ = [[GoStructs_S alloc] initWithRef:ret0__ref]; + } + } + NSString* _error = go_seq_readUTF8(&out_); + if ([_error length] != 0 && error != nil) { + NSMutableDictionary *details = [NSMutableDictionary dictionary]; + [details setValue:_error forKey:NSLocalizedDescriptionKey]; + *error = [NSError errorWithDomain:errDomain code:1 userInfo:details]; + } + go_seq_free(&in_); + go_seq_free(&out_); + return ([_error length] == 0); +} + - (double)Sum { GoSeq in_ = {}; GoSeq out_ = {};