PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/trunk/Lib/pike/std_string.i

#
Swig | 60 lines | 38 code | 16 blank | 6 comment | 0 complexity | bd7e2e35774d6466f727c48eeb779e16 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* -----------------------------------------------------------------------------
  2. * std_string.i
  3. *
  4. * SWIG typemaps for std::string
  5. * ----------------------------------------------------------------------------- */
  6. %{
  7. #include <string>
  8. %}
  9. namespace std {
  10. %naturalvar string;
  11. class string;
  12. /* Overloading check */
  13. %typemap(typecheck) string = char *;
  14. %typemap(typecheck) const string & = char *;
  15. %typemap(in, pikedesc="tStr") string {
  16. if ($input.type != T_STRING)
  17. Pike_error("Bad argument: Expected a string.\n");
  18. $1.assign(STR0($input.u.string));
  19. }
  20. %typemap(in, pikedesc="tStr") const string & (std::string temp) {
  21. if ($input.type != T_STRING)
  22. Pike_error("Bad argument: Expected a string.\n");
  23. temp.assign(STR0($input.u.string));
  24. $1 = &temp;
  25. }
  26. %typemap(out, pikedesc="tStr") string "push_text($1.c_str());";
  27. %typemap(out, pikedesc="tStr") const string & "push_text($1->c_str());";
  28. %typemap(directorin) string, const string &, string & "$1.c_str()";
  29. %typemap(directorin) string *, const string * "$1->c_str()";
  30. %typemap(directorout) string {
  31. if ($input.type == T_STRING)
  32. $result.assign(STR0($input.u.string));
  33. else
  34. throw Swig::DirectorTypeMismatchException("string expected");
  35. }
  36. %typemap(directorout) const string & (std::string temp) {
  37. if ($input.type == T_STRING) {
  38. temp.assign(STR0($input.u.string));
  39. $result = &temp;
  40. } else {
  41. throw Swig::DirectorTypeMismatchException("string expected");
  42. }
  43. }
  44. }