When wrapping C++ code, generate code which uses
std::string::assign(PTR, LEN) rather than assigning std::string(PTR, LEN). Using assign generates more efficient code (tested with GCC 4.1.2). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9936 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ef4ca158de
commit
c836c81acb
11 changed files with 46 additions and 45 deletions
|
|
@ -85,16 +85,16 @@ namespace std {
|
|||
/* Overloading check */
|
||||
%typemap(in) string {
|
||||
if (caml_ptr_check($input))
|
||||
$1 = std::string((char *)caml_ptr_val($input,0),
|
||||
caml_string_len($input));
|
||||
$1.assign((char *)caml_ptr_val($input,0),
|
||||
caml_string_len($input));
|
||||
else
|
||||
SWIG_exception(SWIG_TypeError, "string expected");
|
||||
}
|
||||
|
||||
%typemap(in) const string & (std::string temp) {
|
||||
if (caml_ptr_check($input)) {
|
||||
temp = std::string((char *)caml_ptr_val($input,0),
|
||||
caml_string_len($input));
|
||||
temp.assign((char *)caml_ptr_val($input,0),
|
||||
caml_string_len($input));
|
||||
$1 = &temp;
|
||||
} else {
|
||||
SWIG_exception(SWIG_TypeError, "string expected");
|
||||
|
|
@ -103,8 +103,8 @@ namespace std {
|
|||
|
||||
%typemap(in) string & (std::string temp) {
|
||||
if (caml_ptr_check($input)) {
|
||||
temp = std::string((char *)caml_ptr_val($input,0),
|
||||
caml_string_len($input));
|
||||
temp.assign((char *)caml_ptr_val($input,0),
|
||||
caml_string_len($input));
|
||||
$1 = &temp;
|
||||
} else {
|
||||
SWIG_exception(SWIG_TypeError, "string expected");
|
||||
|
|
@ -131,8 +131,8 @@ namespace std {
|
|||
}
|
||||
|
||||
%typemap(directorout) string {
|
||||
$result = std::string((char *)caml_ptr_val($input,0),
|
||||
caml_string_len($input));
|
||||
$result.assign((char *)caml_ptr_val($input,0),
|
||||
caml_string_len($input));
|
||||
}
|
||||
|
||||
%typemap(out) string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue