Add support for the Go programming language.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12108 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Ian Lance Taylor 2010-06-10 01:13:31 +00:00
commit 5af2978f77
259 changed files with 16159 additions and 14 deletions

View file

@ -0,0 +1,125 @@
package main
import . "./overload_simple"
func main() {
if Foofn(3) != "foo:int" {
panic("foo(int)")
}
if Foofn(float64(3.0)) != "foo:double" {
panic("foo(double)")
}
if Foofn("hello") != "foo:char *" {
panic("foo(char *)")
}
f := NewFoo()
b := NewBar()
if Foofn(f) != "foo:Foo *" {
panic("foo(Foo *)")
}
if Foofn(b) != "foo:Bar *" {
panic("foo(Bar *)")
}
v := Malloc_void(32)
if Foofn(v) != "foo:void *" {
panic("foo(void *)")
}
s := NewSpam()
if s.Foofn(3) != "foo:int" {
panic("Spam::foo(int)")
}
if s.Foofn(float64(3.0)) != "foo:double" {
panic("Spam::foo(double)")
}
if s.Foofn("hello") != "foo:char *" {
panic("Spam::foo(char *)")
}
if s.Foofn(f) != "foo:Foo *" {
panic("Spam::foo(Foo *)")
}
if s.Foofn(b) != "foo:Bar *" {
panic("Spam::foo(Bar *)")
}
if s.Foofn(v) != "foo:void *" {
panic("Spam::foo(void *)")
}
if SpamBar(3) != "bar:int" {
panic("Spam::bar(int)")
}
if SpamBar(float64(3.0)) != "bar:double" {
panic("Spam::bar(double)")
}
if SpamBar("hello") != "bar:char *" {
panic("Spam::bar(char *)")
}
if SpamBar(f) != "bar:Foo *" {
panic("Spam::bar(Foo *)")
}
if SpamBar(b) != "bar:Bar *" {
panic("Spam::bar(Bar *)")
}
if SpamBar(v) != "bar:void *" {
panic("Spam::bar(void *)")
}
// Test constructors
s = NewSpam()
if s.GetXtype() != "none" {
panic("Spam()")
}
s = NewSpam(3)
if s.GetXtype() != "int" {
panic("Spam(int)")
}
s = NewSpam(float64(3.4))
if s.GetXtype() != "double" {
panic("Spam(double)")
}
s = NewSpam("hello")
if s.GetXtype() != "char *" {
panic("Spam(char *)")
}
s = NewSpam(f)
if s.GetXtype() != "Foo *" {
panic("Spam(Foo *)")
}
s = NewSpam(b)
if s.GetXtype() != "Bar *" {
panic("Spam(Bar *)")
}
s = NewSpam(v)
if s.GetXtype() != "void *" {
panic("Spam(void *)")
}
Free_void(v)
a := NewClassA()
_ = a.Method1(1)
}