Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix directed method returning class without default ctor #2645

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Examples/test-suite/director_classes.i
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool PrintDebug = false;

struct DoubleHolder
{
DoubleHolder(double v = 0.0) : val(v) {}
DoubleHolder(double v) : val(v) {}
double val;
};

Expand Down
9 changes: 8 additions & 1 deletion Source/Modules/go.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4017,7 +4017,14 @@ class GO:public Language {
Wrapper_add_localv(w, "c_result", SwigType_lstr(result, "c_result"), "= 0", NIL);
}
} else {
String *cres = SwigType_lstr(result, "c_result");
String *cres;
SwigType *vt = cplus_value_type(result);
if (!vt) {
cres = SwigType_lstr(result, "c_result");
} else {
cres = SwigType_lstr(vt, "c_result");
Delete(vt);
}
Printf(w->code, "%s;\n", cres);
Delete(cres);
}
Expand Down
9 changes: 8 additions & 1 deletion Source/Modules/ocaml.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,14 @@ class OCAML:public Language {
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL);
}
} else {
String *cres = SwigType_lstr(returntype, "c_result");
String *cres;
SwigType *vt = cplus_value_type(returntype);
if (!vt) {
cres = SwigType_lstr(returntype, "c_result");
} else {
cres = SwigType_lstr(vt, "c_result");
Delete(vt);
}
Printf(w->code, "%s;\n", cres);
Delete(cres);
}
Expand Down
9 changes: 8 additions & 1 deletion Source/Modules/octave.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,14 @@ class OCTAVE:public Language {
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL);
}
} else {
String *cres = SwigType_lstr(returntype, "c_result");
String *cres;
SwigType *vt = cplus_value_type(returntype);
if (!vt) {
cres = SwigType_lstr(returntype, "c_result");
} else {
cres = SwigType_lstr(vt, "c_result");
Delete(vt);
}
Printf(w->code, "%s;\n", cres);
Delete(cres);
}
Expand Down
9 changes: 8 additions & 1 deletion Source/Modules/perl5.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2121,7 +2121,14 @@ class PERL5:public Language {
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL);
}
} else {
String *cres = SwigType_lstr(returntype, "c_result");
String *cres;
SwigType *vt = cplus_value_type(returntype);
if (!vt) {
cres = SwigType_lstr(returntype, "c_result");
} else {
cres = SwigType_lstr(vt, "c_result");
Delete(vt);
}
Printf(w->code, "%s;\n", cres);
Delete(cres);
}
Expand Down
9 changes: 8 additions & 1 deletion Source/Modules/php.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2327,7 +2327,14 @@ class PHP : public Language {
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL);
}
} else {
String *cres = SwigType_lstr(returntype, "c_result");
String *cres;
SwigType *vt = cplus_value_type(returntype);
if (!vt) {
cres = SwigType_lstr(returntype, "c_result");
} else {
cres = SwigType_lstr(vt, "c_result");
Delete(vt);
}
Printf(w->code, "%s;\n", cres);
Delete(cres);
}
Expand Down
9 changes: 8 additions & 1 deletion Source/Modules/python.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5403,7 +5403,14 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL);
}
} else {
String *cres = SwigType_lstr(returntype, "c_result");
String *cres;
SwigType *vt = cplus_value_type(returntype);
if (!vt) {
cres = SwigType_lstr(returntype, "c_result");
} else {
cres = SwigType_lstr(vt, "c_result");
Delete(vt);
}
Printf(w->code, "%s;\n", cres);
Delete(cres);
}
Expand Down
9 changes: 8 additions & 1 deletion Source/Modules/ruby.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3115,7 +3115,14 @@ class RUBY:public Language {
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL);
}
} else {
String *cres = SwigType_lstr(returntype, "c_result");
String *cres;
SwigType *vt = cplus_value_type(returntype);
if (!vt) {
cres = SwigType_lstr(returntype, "c_result");
} else {
cres = SwigType_lstr(vt, "c_result");
Delete(vt);
}
Printf(w->code, "%s;\n", cres);
Delete(cres);
}
Expand Down
Loading