diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /devtools/swigwin-1.3.34/Lib/csharp/std_string.i | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'devtools/swigwin-1.3.34/Lib/csharp/std_string.i')
| -rw-r--r-- | devtools/swigwin-1.3.34/Lib/csharp/std_string.i | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/devtools/swigwin-1.3.34/Lib/csharp/std_string.i b/devtools/swigwin-1.3.34/Lib/csharp/std_string.i new file mode 100644 index 0000000..d296927 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/csharp/std_string.i @@ -0,0 +1,114 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_string.i + * + * Typemaps for std::string and const std::string& + * These are mapped to a C# String and are passed around by value. + * + * To use non-const std::string references use the following %apply. Note + * that they are passed by value. + * %apply const std::string & {std::string &}; + * ----------------------------------------------------------------------------- */ + +%{ +#include <string> +%} + +namespace std { + +%naturalvar string; + +class string; + +// string +%typemap(ctype) string "char *" +%typemap(imtype) string "string" +%typemap(cstype) string "string" + +%typemap(csdirectorin) string "$iminput" +%typemap(csdirectorout) string "$cscall" + +%typemap(in, canthrow=1) string +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return $null; + } + $1.assign($input); %} +%typemap(out) string %{ $result = SWIG_csharp_string_callback($1.c_str()); %} + +%typemap(directorout, canthrow=1) string +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return $null; + } + $result.assign($input); %} + +%typemap(directorin) string %{ $input = SWIG_csharp_string_callback($1.c_str()); %} + +%typemap(csin) string "$csinput" +%typemap(csout, excode=SWIGEXCODE) string { + string ret = $imcall;$excode + return ret; + } + +%typemap(typecheck) string = char *; + +%typemap(throws, canthrow=1) string +%{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str()); + return $null; %} + +// const string & +%typemap(ctype) const string & "char *" +%typemap(imtype) const string & "string" +%typemap(cstype) const string & "string" + +%typemap(csdirectorin) const string & "$iminput" +%typemap(csdirectorout) const string & "$cscall" + +%typemap(in, canthrow=1) const string & +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return $null; + } + std::string $1_str($input); + $1 = &$1_str; %} +%typemap(out) const string & %{ $result = SWIG_csharp_string_callback($1->c_str()); %} + +%typemap(csin) const string & "$csinput" +%typemap(csout, excode=SWIGEXCODE) const string & { + string ret = $imcall;$excode + return ret; + } + +%typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string & +%{ if (!$input) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + return $null; + } + /* possible thread/reentrant code problem */ + static std::string $1_str; + $1_str = $input; + $result = &$1_str; %} + +%typemap(directorin) const string & %{ $input = SWIG_csharp_string_callback($1.c_str()); %} + +%typemap(csvarin, excode=SWIGEXCODE2) const string & %{ + set { + $imcall;$excode + } %} +%typemap(csvarout, excode=SWIGEXCODE2) const string & %{ + get { + string ret = $imcall;$excode + return ret; + } %} + +%typemap(typecheck) const string & = char *; + +%typemap(throws, canthrow=1) const string & +%{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str()); + return $null; %} + +} + |