2
0
mirror of synced 2025-02-23 06:48:15 +00:00

bind: skip incompatible constructors in ObjC bindings

Fixes golang/go#21523

Change-Id: I1244e296ac4eeb0d10847e73216e4a25a3533292
Reviewed-on: https://go-review.googlesource.com/101115
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
Elias Naur 2018-03-16 10:13:05 +01:00
parent c922c29296
commit 70293e6c50
2 changed files with 13 additions and 0 deletions

View File

@ -1161,6 +1161,10 @@ func (g *ObjcGen) genStructM(obj *types.TypeName, t *types.Struct) {
cons := g.constructors[obj] cons := g.constructors[obj]
if oinf == nil { if oinf == nil {
for _, f := range cons { for _, f := range cons {
if !g.isSigSupported(f.Type()) {
g.Printf("// skipped constructor %s.%s with unsupported parameter or return types\n\n", obj, f.Name())
continue
}
g.genInitM(obj, f) g.genInitM(obj, f)
} }
} }

View File

@ -9,6 +9,7 @@ package testpkg
//go:generate gobind -lang=go -outdir=go_testpkg . //go:generate gobind -lang=go -outdir=go_testpkg .
//go:generate gobind -lang=java -outdir=. . //go:generate gobind -lang=java -outdir=. .
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
@ -609,3 +610,11 @@ func TestSIGPIPE() {
type Testpkg interface{} type Testpkg interface{}
func ClashingParameterFromOtherPackage(_ *secondpkg.Secondpkg) {} func ClashingParameterFromOtherPackage(_ *secondpkg.Secondpkg) {}
type MyStruct struct {
}
// Test that constructors with incompatible signatures are ignored.
func NewMyStruct(ctx context.Context) *MyStruct {
return nil
}