PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1-3-25/SWIG/Examples/test-suite/li_std_string.i

#
Swig | 84 lines | 63 code | 21 blank | 0 comment | 0 complexity | a074b5ea4c92ced503dc08d5799e9335 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module li_std_string
  2. %include "std_string.i"
  3. %inline %{
  4. std::string test_value(std::string x) {
  5. return x;
  6. }
  7. const std::string& test_const_reference(const std::string &x) {
  8. return x;
  9. }
  10. void test_pointer(std::string *x) {
  11. }
  12. std::string *test_pointer_out() {
  13. static std::string x = "x";
  14. return &x;
  15. }
  16. void test_const_pointer(const std::string *x) {
  17. }
  18. const std::string *test_const_pointer_out() {
  19. static std::string x = "x";
  20. return &x;
  21. }
  22. void test_reference(std::string &x) {
  23. }
  24. std::string& test_reference_out() {
  25. static std::string x = "test_reference_out message";
  26. return x;
  27. }
  28. void test_throw() throw(std::string){
  29. static std::string x = "test_throw message";
  30. throw x;
  31. }
  32. void test_const_reference_throw() throw(const std::string &){
  33. static std::string x = "test_const_reference_throw message";
  34. throw x;
  35. }
  36. void test_pointer_throw() throw(std::string *) {
  37. throw new std::string("foo");
  38. }
  39. void test_const_pointer_throw() throw(const std::string *) {
  40. throw new std::string("foo");
  41. }
  42. %}
  43. %apply const std::string& { std::string *GlobalString2,
  44. std::string *MemberString2,
  45. std::string *Structure::StaticMemberString2 };
  46. %inline %{
  47. std::string GlobalString;
  48. std::string GlobalString2 = "global string 2";
  49. struct Structure {
  50. std::string MemberString;
  51. std::string MemberString2;
  52. static std::string StaticMemberString;
  53. static std::string StaticMemberString2;
  54. const std::string ConstMemberString;
  55. static const std::string ConstStaticMemberString;
  56. Structure() : MemberString2("member string 2"), ConstMemberString("const member string") {}
  57. };
  58. %}
  59. %{
  60. std::string Structure::StaticMemberString = "static member string";
  61. std::string Structure::StaticMemberString2 = "static member string 2";
  62. const std::string Structure::ConstStaticMemberString = "const static member string";
  63. %}