From: <ian...@us...> - 2011-02-20 05:48:31
|
Revision: 12498 http://swig.svn.sourceforge.net/swig/?rev=12498&view=rev Author: ianlancetaylor Date: 2011-02-20 05:48:25 +0000 (Sun, 20 Feb 2011) Log Message: ----------- For Go: Fix handling of INPUT variables when using typemaps.i. This fixes cases where the gotype typemap is used to produce a simple Go type for a non-simple C/C++ type. Modified Paths: -------------- trunk/Examples/go/pointer/runme.go trunk/Source/Modules/go.cxx Modified: trunk/Examples/go/pointer/runme.go =================================================================== --- trunk/Examples/go/pointer/runme.go 2011-02-20 04:47:17 UTC (rev 12497) +++ trunk/Examples/go/pointer/runme.go 2011-02-20 05:48:25 UTC (rev 12498) @@ -32,7 +32,7 @@ // Now try the typemap library // Now it is no longer necessary to manufacture pointers. - // Instead we use a single element array which in Java is modifiable. + // Instead we use a single element slice which in Go is modifiable. fmt.Println("Trying the typemap library") r := []int{0} Modified: trunk/Source/Modules/go.cxx =================================================================== --- trunk/Source/Modules/go.cxx 2011-02-20 04:47:17 UTC (rev 12497) +++ trunk/Source/Modules/go.cxx 2011-02-20 05:48:25 UTC (rev 12498) @@ -4533,6 +4533,20 @@ bool is_member = Strcmp(gt, "_swig_memberptr") == 0; bool is_complex64 = Strcmp(gt, "complex64") == 0; bool is_complex128 = Strcmp(gt, "complex128") == 0; + bool is_char = false; + bool is_short = false; + bool is_int = false; + bool is_long = false; + bool is_float = false; + bool is_double = false; + if ((n != NULL && Getattr(n, "tmap:gotype") != NULL) || hasGoTypemap(type)) { + is_char = Strcmp(gt, "int8") == 0 || Strcmp(gt, "uint8") == 0 || Strcmp(gt, "byte") == 0; + is_short = Strcmp(gt, "int16") == 0 || Strcmp(gt, "uint16") == 0; + is_int = Strcmp(gt, "int") == 0 || Strcmp(gt, "int32") == 0 || Strcmp(gt, "uint32") == 0; + is_long = Strcmp(gt, "int64") == 0 || Strcmp(gt, "uint64") == 0; + is_float = Strcmp(gt, "float32") == 0; + is_double = Strcmp(gt, "float64") == 0; + } Delete(gt); String *ret; @@ -4588,7 +4602,21 @@ } } Delete(t); - return SwigType_lstr(type, name); + if (is_char) { + ret = NewString("char "); + } else if (is_short) { + ret = NewString("short "); + } else if (is_int) { + ret = NewString("int "); + } else if (is_long) { + ret = NewString("long long "); + } else if (is_float) { + ret = NewString("float "); + } else if (is_double) { + ret = NewString("double "); + } else { + return SwigType_lstr(type, name); + } } if (SwigType_isreference(type)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |