/trunk/Examples/test-suite/cpp_typedef.i

# · Swig · 50 lines · 39 code · 11 blank · 0 comment · 0 complexity · 785c624dce1f77a1af3bdec18b3d0e3a MD5 · raw file

  1. // This file tests SWIG's tracking of C++ typedef declarations
  2. %module cpp_typedef
  3. %{
  4. class Bar {
  5. public:
  6. };
  7. %}
  8. %inline %{
  9. class Foo {
  10. public:
  11. typedef Bar SomeBar;
  12. typedef SomeBar SomeOtherBar;
  13. SomeOtherBar bar() {
  14. SomeOtherBar b;
  15. return b;
  16. }
  17. static SomeOtherBar sbar() {
  18. SomeOtherBar b;
  19. return b;
  20. }
  21. };
  22. // Test that the correct types are used for typedef struct declarations
  23. typedef struct {
  24. int something;
  25. void m() {}
  26. } UnnamedStruct;
  27. typedef struct NamedStruct {
  28. int something;
  29. void m() {}
  30. } TypedefNamedStruct;
  31. typedef TypedefNamedStruct DoubleTypedef;
  32. class Test {
  33. public:
  34. UnnamedStruct test1(UnnamedStruct a) {return a;};
  35. struct NamedStruct test2(struct NamedStruct a) {return a;};
  36. TypedefNamedStruct test3(TypedefNamedStruct a) {return a;};
  37. DoubleTypedef test4(DoubleTypedef a) {return a;};
  38. };
  39. %}