Remove the -rename option in the Go language support. Do a much

better job of checking for name conflicts.  Ignore conflicting names
with a warning.  Adjust the testsuite accordingly.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12135 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Ian Lance Taylor 2010-06-17 18:59:26 +00:00
commit 2970f53c21
18 changed files with 232 additions and 94 deletions

View file

@ -5,6 +5,7 @@ This testcase primarily test constant pointers, eg int* const. Only a getter is
%module constant_pointers
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'Foo' due to Go name ('Foo') conflict with 'foo' */
%inline %{

View file

@ -1,4 +1,7 @@
%module(directors="1") director_finalizer
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'deleteFoo' due to Go name ('DeleteFoo') conflict with '~Foo' */
%{
int status = 0;

View file

@ -43,6 +43,8 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Instances::memberinstance2;
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Instances::memberinstance3;
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'one' due to Go name ('ObscureOne') conflict with 'Obscure::One' */
%inline %{
enum { AnonEnum1, AnonEnum2 = 100 };

View file

@ -21,22 +21,6 @@ top_builddir = @top_builddir@
include $(srcdir)/../common.mk
# Custom tests - tests with additional commandline options
constant_pointers.cpptest: SWIGOPT += -rename foo=foofn
director_enum.cpptest: SWIGOPT += -rename Hello=Helloe
director_finalizer.cpptest: SWIGOPT += -rename deleteFoo=deleteFooFn
enum_thorough.cpptest: SWIGOPT += -rename One=Onee -rename Two=Twoe
mixed_types.cpptest: SWIGOPT += -rename Hello=Helloe
overload_simple.cpptest: SWIGOPT += -rename foo=foofn
smart_pointer_extend.cpptest: SWIGOPT += -rename CPtrFoo=CPtrFoos
smart_pointer_member.cpptest: SWIGOPT += -rename Foo=Foos
special_variable_macros.cpptest: SWIGOPT += -rename Name=Names
template_partial_specialization.cpptest: SWIGOPT += -rename b=bfn
template_partial_specialization_typedef.cpptest: SWIGOPT += -rename b=bfn
template_specialization_enum.cpptest: SWIGOPT += -rename Hello=Helloe
preproc.ctest: SWIGOPT += -rename a5=a5c -rename a6=a6c
mod.multicpptest: SWIGOPT += -rename GetC=GetCFn
.SUFFIXES: .cpptest .ctest .multicpptest
# Rules for the different types of tests

View file

@ -3,7 +3,7 @@ package main
import "./director_enum"
type MyFoo struct{} // From director_enum.Foo
func (p *MyFoo) Say_hi(val director_enum.EnumDirectorHelloe) director_enum.EnumDirectorHelloe {
func (p *MyFoo) Say_hi(val director_enum.EnumDirectorHello) director_enum.EnumDirectorHello {
return val
}

View file

@ -3,57 +3,57 @@ package main
import . "./overload_simple"
func main() {
if Foofn(3) != "foo:int" {
if Foo(3) != "foo:int" {
panic("foo(int)")
}
if Foofn(float64(3.0)) != "foo:double" {
if Foo(float64(3.0)) != "foo:double" {
panic("foo(double)")
}
if Foofn("hello") != "foo:char *" {
if Foo("hello") != "foo:char *" {
panic("foo(char *)")
}
f := NewFoo()
f := NewFoos()
b := NewBar()
if Foofn(f) != "foo:Foo *" {
if Foo(f) != "foo:Foo *" {
panic("foo(Foo *)")
}
if Foofn(b) != "foo:Bar *" {
if Foo(b) != "foo:Bar *" {
panic("foo(Bar *)")
}
v := Malloc_void(32)
if Foofn(v) != "foo:void *" {
if Foo(v) != "foo:void *" {
panic("foo(void *)")
}
s := NewSpam()
if s.Foofn(3) != "foo:int" {
if s.Foo(3) != "foo:int" {
panic("Spam::foo(int)")
}
if s.Foofn(float64(3.0)) != "foo:double" {
if s.Foo(float64(3.0)) != "foo:double" {
panic("Spam::foo(double)")
}
if s.Foofn("hello") != "foo:char *" {
if s.Foo("hello") != "foo:char *" {
panic("Spam::foo(char *)")
}
if s.Foofn(f) != "foo:Foo *" {
if s.Foo(f) != "foo:Foo *" {
panic("Spam::foo(Foo *)")
}
if s.Foofn(b) != "foo:Bar *" {
if s.Foo(b) != "foo:Bar *" {
panic("Spam::foo(Bar *)")
}
if s.Foofn(v) != "foo:void *" {
if s.Foo(v) != "foo:void *" {
panic("Spam::foo(void *)")
}

View file

@ -4,7 +4,7 @@ import "fmt"
import . "./smart_pointer_member"
func main() {
f := NewFoos()
f := NewFoo()
f.SetY(1)
if f.GetY() != 1 {
@ -24,7 +24,7 @@ func main() {
panic(0)
}
if b.GetZ() != GetFoosZ() {
if b.GetZ() != GetFooZ() {
panic(0)
}
}

View file

@ -3,7 +3,7 @@ package main
import "./special_variable_macros"
func main() {
name := special_variable_macros.NewNames()
name := special_variable_macros.NewName()
if special_variable_macros.TestFred(name) != "none" {
panic("test failed")
}

View file

@ -3,6 +3,8 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) hi; /* Ruby, wrong constant name */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) hello; /* Ruby, wrong constant name */
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'hello' due to Go name ('Hello') conflict with 'Hello' */
%inline
{
const void* ref_pointer(const void*& a) {

View file

@ -14,7 +14,10 @@
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) fid;
#endif
#ifdef SWIGGO
%warnfilter(SWIGWARN_PARSE_KEYWORD) type; // 'type' is a Go keyword, renamed as 'Xtype'
%rename(Foos) Foo;
#endif
#ifndef SWIG_NO_OVERLOAD
%immutable Spam::type;

View file

@ -7,6 +7,8 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_PROTOTYPES; /* Ruby, wrong constant name */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_TOKEN_PASTE; /* Ruby, wrong constant name */
#pragma SWIG nowarn=890 /* lots of Go name conflicts */
/* check __cplusplus case */
%header
%{

View file

@ -1,6 +1,6 @@
%module smart_pointer_member
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'foo' due to Go name ('Foo') conflict with 'Foo' */
%inline %{

View file

@ -3,6 +3,8 @@
// test $typemap() special variable function
// these tests are not typical of how $typemap() should be used, but it checks that it is mostly working
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'NewName' due to Go name ('NewName') conflict with 'Name' */
%inline %{
struct Name {
Name(const char *n="none") : name(n) {}

View file

@ -3,6 +3,7 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Hello; /* Ruby, wrong class name */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Hi; /* Ruby, wrong class name */
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'hello due to Go name ('Hello) conflict with 'Hello' */
%inline %{