remove unnecessary temporary variable when wrapping return by reference

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11126 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-02-12 21:16:03 +00:00
commit f9abd71f76
2 changed files with 26 additions and 10 deletions

View file

@ -1,6 +1,29 @@
Version 1.3.39 (in progress)
============================
2008-02-12: wsfulton
Remove unnecessary temporary variable when wrapping return values that are references.
Example of generated code for wrapping:
struct XYZ {
std::string& refReturn();
};
used to be:
std::string *result = 0 ;
...
{
std::string &_result_ref = (arg1)->refReturn();
result = (std::string *) &_result_ref;
}
Now it is:
std::string *result = 0 ;
...
result = (std::string *) &(arg1)->refReturn();
2008-02-08: bhy
Change the SIZE mapped by %pybuffer_mutable_binary and %pybuffer_binary in pybuffer.i from
the length of the buffer to the number of items in the buffer.

View file

@ -260,10 +260,9 @@ String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or
break;
case T_REFERENCE:
{
String *str = SwigType_str(t, "_result_ref");
Printf(fcall, "{\n");
Printf(fcall, "%s = ", str);
Delete(str);
String *lstr = SwigType_lstr(t, 0);
Printf(fcall, "%s = (%s) &", name, lstr);
Delete(lstr);
}
break;
case T_USER:
@ -290,12 +289,6 @@ String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or
Append(fcall, ";");
}
if (SwigType_type(t) == T_REFERENCE) {
String *lstr = SwigType_lstr(t, 0);
Printf(fcall, "\n%s = (%s) &_result_ref;\n", name, lstr);
Append(fcall, "}");
Delete(lstr);
}
return fcall;
}