[Go] Fix bug with ignored destructor--generated code did not compile.

This commit is contained in:
Ian Lance Taylor 2015-05-18 09:53:13 -07:00
parent 1e19e4bd45
commit 5bca063536
2 changed files with 41 additions and 25 deletions

View File

@ -10,6 +10,7 @@
%ignore OverloadedProtectedMethod(int n, int xoffset = 0, int yoffset = 0);
%ignore DIgnoreConstructor(bool b);
%ignore DIgnoreOnlyConstructor(bool b);
%ignore DIgnoreDestructor::~DIgnoreDestructor;
%ignore Pointers;
%ignore References;
%ignore PublicMethod1;
@ -101,6 +102,13 @@ class DIgnoreOnlyConstructor
DIgnoreOnlyConstructor(bool b) {}
};
class DIgnoreDestructor
{
public:
DIgnoreDestructor() {}
virtual ~DIgnoreDestructor() {}
};
%{
class DIgnoreConstructor
{
@ -118,5 +126,12 @@ class DIgnoreOnlyConstructor
private: // Hide constructor
DIgnoreOnlyConstructor(bool b) {}
};
%}
class DIgnoreDestructor
{
public:
DIgnoreDestructor() {}
virtual ~DIgnoreDestructor() {}
};
%}

View File

@ -3891,36 +3891,37 @@ private:
String *director_struct_name = NewString("_swig_Director");
Append(director_struct_name, cn);
Printv(f_c_directors_h, " virtual ~SwigDirector_", class_name, "()", NULL);
String *throws = buildThrow(n);
if (throws) {
Printv(f_c_directors_h, " ", throws, NULL);
}
Printv(f_c_directors_h, ";\n", NULL);
String *director_sig = NewString("");
Printv(director_sig, "SwigDirector_", class_name, "::~SwigDirector_", class_name, "()", NULL);
if (throws) {
Printv(director_sig, " ", throws, NULL);
Delete(throws);
}
Printv(director_sig, "\n", NULL);
Printv(director_sig, "{\n", NULL);
if (!is_ignored) {
Printv(f_c_directors_h, " virtual ~SwigDirector_", class_name, "()", NULL);
String *throws = buildThrow(n);
if (throws) {
Printv(f_c_directors_h, " ", throws, NULL);
}
Printv(f_c_directors_h, ";\n", NULL);
String *director_sig = NewString("");
Printv(director_sig, "SwigDirector_", class_name, "::~SwigDirector_", class_name, "()", NULL);
if (throws) {
Printv(director_sig, " ", throws, NULL);
Delete(throws);
}
Printv(director_sig, "\n", NULL);
Printv(director_sig, "{\n", NULL);
makeDirectorDestructorWrapper(go_name, director_struct_name, director_sig);
Printv(f_c_directors, " delete swig_mem;\n", NULL);
Printv(f_c_directors, "}\n\n", NULL);
Delete(director_sig);
}
Printv(f_c_directors, "}\n\n", NULL);
Delete(director_sig);
Delete(go_name);
Delete(cn);
Delete(director_struct_name);