bind: generate Java constructors for every exported struct

A recent CL added Java constructors to generated classes that extends
or implements other Java classes and interfaces. Constructors for a
struct S are Go functions on the form

func NewS...(...) *S

If no such constructors exists, a default empty constructor is
generated.

Expand that to cover every exported Go struct.

Fixes golang/go#17086

Change-Id: I910aba13d5884c3f67c946c62a8ac4a3db8e2ea7
Reviewed-on: https://go-review.googlesource.com/29710
Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
Elias Naur
2016-10-05 07:47:24 +00:00
parent 89b8360218
commit 3f7b83ffd4
13 changed files with 123 additions and 38 deletions
+11
View File
@@ -527,6 +527,17 @@ public class SeqTest extends InstrumentationTestCase {
assertTrue("Go struct passed through Java should not be wrapped", Testpkg.callCDupper(cdup));
}
public void testConstructor() {
Interface i = new Concrete();
i.f();
S2 s = new S2(1, 2);
assertEquals("new S2().sum", 3.0, s.sum());
assertEquals("new S2().tryTwoStrings", "gostring", s.tryTwoStrings("go", "string"));
new S3();
S4 s4 = new S4(123);
assertEquals("Constructor argument", 123, s4.getI());
}
public void testEmptyError() {
try {
Testpkg.emptyError();