PageRenderTime 37ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1.3.35/Examples/test-suite/python/input.i

#
Swig | 41 lines | 35 code | 6 blank | 0 comment | 0 complexity | 3a775d0af78830a982ee9bb7d9d63f54 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module input
  2. %apply int *INPUT {int *bar};
  3. %typemap(out, fragment=SWIG_From_frag(int)) int *foo {
  4. if ($1) {
  5. $result = SWIG_From(int)(*$1);
  6. } else {
  7. $result = SWIG_Py_Void();
  8. }
  9. }
  10. %inline
  11. {
  12. struct Foo {
  13. int *foo(int *bar = 0) {
  14. if (bar) {
  15. *bar *= 2;
  16. }
  17. return (bar) ? bar : 0;
  18. }
  19. };
  20. }
  21. %include std_string.i
  22. %apply std::string *INPUT {std::string *bar};
  23. %typemap(out, fragment=SWIG_From_frag(std::string)) std::string *sfoo {
  24. if ($1) {
  25. $result = SWIG_From(std::string)(*$1);
  26. } else {
  27. $result = SWIG_Py_Void();
  28. }
  29. }
  30. %inline %{
  31. std::string *sfoo(std::string *bar = 0) {
  32. if (bar) *bar += " world";
  33. return (bar) ? bar : 0;
  34. }
  35. %}