bind: correct methods' return arg type mapping in obj-c binding.
Change-Id: Ieda05982c7f894c5603103b8890658e682e97423 Reviewed-on: https://go-review.googlesource.com/11307 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
parent
4d3dd47e87
commit
3a9b5b50ac
@ -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, " "))
|
||||
}
|
||||
|
4
bind/testdata/structs.go
vendored
4
bind/testdata/structs.go
vendored
@ -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
|
||||
}
|
||||
|
26
bind/testdata/structs.go.golden
vendored
26
bind/testdata/structs.go.golden
vendored
@ -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)
|
||||
}
|
||||
|
||||
|
17
bind/testdata/structs.java.golden
vendored
17
bind/testdata/structs.java.golden
vendored
@ -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();
|
||||
|
1
bind/testdata/structs.objc.h.golden
vendored
1
bind/testdata/structs.objc.h.golden
vendored
@ -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
|
||||
|
||||
|
26
bind/testdata/structs.objc.m.golden
vendored
26
bind/testdata/structs.objc.m.golden
vendored
@ -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_ = {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user