PageRenderTime 46ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 1ms

/tags/ttn-post-libtool-1-4-3-upgrade/SWIG/Lib/mzscheme/std_string.i

#
Swig | 56 lines | 41 code | 14 blank | 1 comment | 0 complexity | 51ee64101643b0ad79c70147558aef78 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. //
  2. // SWIG typemaps for std::string types
  3. // Luigi Ballabio
  4. // Apr 8, 2002
  5. //
  6. // MzScheme implementation
  7. // ------------------------------------------------------------------------
  8. // std::string is typemapped by value
  9. // This can prevent exporting methods which return a string
  10. // in order for the user to modify it.
  11. // However, I think I'll wait until someone asks for it...
  12. // ------------------------------------------------------------------------
  13. %include exception.i
  14. %{
  15. #include <string>
  16. %}
  17. namespace std {
  18. class string;
  19. /* Overloading check */
  20. %typemap(typecheck) string = char *;
  21. %typemap(typecheck) const string & = char *;
  22. %typemap(in) string {
  23. if (SCHEME_STRINGP($input))
  24. $1 = std::string(SCHEME_STR_VAL($input));
  25. else
  26. SWIG_exception(SWIG_TypeError, "string expected");
  27. }
  28. %typemap(in) const string & (std::string temp) {
  29. if (SCHEME_STRINGP($input)) {
  30. temp = std::string(SCHEME_STR_VAL($input));
  31. $1 = &temp;
  32. } else {
  33. SWIG_exception(SWIG_TypeError, "string expected");
  34. }
  35. }
  36. %typemap(out) string {
  37. $result = scheme_make_string($1.c_str());
  38. }
  39. %typemap(out) const string & {
  40. $result = scheme_make_string($1->c_str());
  41. }
  42. }