From: SourceForge.net <no...@so...> - 2012-09-29 22:16:25
|
Patches item #3573098, was opened at 2012-09-29 15:04 Message generated for change (Comment added) made by nigelchoi You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=301645&aid=3573098&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Nigel Choi (nigelchoi) Assigned to: Ian Lance Taylor (ianlancetaylor) Summary: Go Module Generates Code For Template Member Functions Initial Comment: The Go module generates incorrect cxx code if a base class has templetized member functions. Consider this in example.h : class Top { public: template<typename T> T cast() const { return dynamic_cast<T>(this); } }; class Sub : public Top { }; And this example.i %module example %{ #include "example.h" %} %include "example.h" Running swig -go -c++ example.i Will produce code that looks like: void _wrap_Sub_cast(void *swig_v) { Sub *arg1 = (Sub *) 0 ; T result; ... And compiler error: example_wrap.cxx:333:3: error: use of undeclared identifier 'T' T result; ^ The simple fix is a one-liner applied on top of 2.0.8 . It's also attached. --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -1958,7 +1958,7 @@ private: } String *type = Getattr(ni, "nodeType"); - if (Strcmp(type, "constructor") == 0 || Strcmp(type, "destructor") == 0 || Strcmp(type, "enum") == 0 || Strcmp(type, "using") == 0 || Strcmp(type, "classforward") == 0) { + if (Strcmp(type, "constructor") == 0 || Strcmp(type, "destructor") == 0 || Strcmp(type, "enum") == 0 || Strcmp(type, "using") == 0 || Strcmp(type, "classforward") == 0 || Strcmp(type, "template") == 0) { continue; } String *storage = Getattr(ni, "storage"); ---------------------------------------------------------------------- >Comment By: Nigel Choi (nigelchoi) Date: 2012-09-29 15:16 Message: Ian, knowing that you authored the Go module I assigned this to you. Please let me know if this is done correctly, and if I should assign this to someone else to have the patch reviewed and applied. Thank you. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=301645&aid=3573098&group_id=1645 |