|
Lines 31-38
Link Here
|
| 31 |
const std::string* (std::string temp), const std::string& (std::string temp) |
31 |
const std::string* (std::string temp), const std::string& (std::string temp) |
| 32 |
{ |
32 |
{ |
| 33 |
SV *sv; |
33 |
SV *sv; |
| 34 |
if (!SvROK($input) || !(sv = (SV*)SvRV($input)) || !SvPOK(sv) ) |
34 |
/*support string by value and also by reference */ |
| 35 |
SWIG_croak("Type error in argument $argnum of $symname. Expected a REFERENCE to STRING.\n"); |
35 |
if (SvPOK($input)) |
|
|
36 |
{ /* we get string value */ |
| 37 |
sv = $input; |
| 38 |
} |
| 39 |
else if (!SvROK($input) || !(sv = (SV*)SvRV($input)) || !SvPOK(sv) ) |
| 40 |
{ |
| 41 |
SWIG_croak("Type error in argument $argnum of $symname. Expected a REFERENCE to STRING or STRING.\n"); |
| 42 |
} |
| 36 |
|
43 |
|
| 37 |
STRLEN len; |
44 |
STRLEN len; |
| 38 |
const char *ptr = SvPV(sv, len); |
45 |
const char *ptr = SvPV(sv, len); |
|
Lines 52-58
Link Here
|
| 52 |
|
59 |
|
| 53 |
%typemap(argout) std::string*, std::string& |
60 |
%typemap(argout) std::string*, std::string& |
| 54 |
{ |
61 |
{ |
| 55 |
SV *sv = (SV *)SvRV($input); |
62 |
SV *sv = $input; |
|
|
63 |
if (SvROK($input)) /* input can be reference of bare string */ |
| 64 |
sv = (SV *)SvRV($input); |
| 56 |
sv_setpv(sv, $1->c_str()); |
65 |
sv_setpv(sv, $1->c_str()); |
| 57 |
} |
66 |
} |
| 58 |
|
67 |
|