PageRenderTime 44ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-26/SWIG/Lib/guile/std_string.i

#
Swig | 58 lines | 47 code | 11 blank | 0 comment | 0 complexity | a58a974bf2cc8f680aa7ad858c03f886 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. //
  2. // SWIG typemaps for std::string
  3. // Luigi Ballabio
  4. // Apr 8, 2002
  5. //
  6. // Guile 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. %typemap(typecheck) string = char *;
  20. %typemap(typecheck) const string & = char *;
  21. %typemap(in) string (char* tempptr) {
  22. if (gh_string_p($input)) {
  23. tempptr = SWIG_scm2str($input);
  24. $1 = std::string(tempptr);
  25. if (tempptr) SWIG_free(tempptr);
  26. } else {
  27. SWIG_exception(SWIG_TypeError, "string expected");
  28. }
  29. }
  30. %typemap(in) const string & (std::string temp,
  31. char* tempptr) {
  32. if (gh_string_p($input)) {
  33. tempptr = SWIG_scm2str($input);
  34. temp = std::string(tempptr);
  35. if (tempptr) SWIG_free(tempptr);
  36. $1 = &temp;
  37. } else {
  38. SWIG_exception(SWIG_TypeError, "string expected");
  39. }
  40. }
  41. %typemap(out) string {
  42. $result = gh_str02scm($1.c_str());
  43. }
  44. %typemap(out) const string & {
  45. $result = gh_str02scm($1->c_str());
  46. }
  47. }