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
|
|
@ -97,13 +97,13 @@ namespace std {
|
|||
|
||||
// automatically convert constant std::strings to cl:strings
|
||||
%typemap(ctype) string "char *";
|
||||
%typemap(in) string "$1 = string($input);";
|
||||
%typemap(in) string "$1.assign($input);";
|
||||
%typemap(out) string "$result = (char *)(&$1)->c_str();";
|
||||
%typemap(lisptype) string "cl:string";
|
||||
%typemap(lout) string "(cl::setq ACL_ffresult $body)";
|
||||
|
||||
%typemap(ctype) wstring "wchar_t *";
|
||||
%typemap(in) wstring "$1 = string($input);";
|
||||
%typemap(in) wstring "$1.assign($input);";
|
||||
%typemap(out) wstring "$result = (wchar_t *)(&$1)->c_str();";
|
||||
%typemap(lisptype) wstring "cl:string";
|
||||
%typemap(lout) wstring "(cl::setq ACL_ffresult (excl:native-to-string $body
|
||||
|
|
@ -112,16 +112,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");
|
||||
|
|
@ -130,8 +130,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");
|
||||
|
|
@ -158,8 +158,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