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

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

#
Swig | 106 lines | 88 code | 18 blank | 0 comment | 0 complexity | c3c5e954e86927fda02e64fa3ec3763f MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module(directors="1") director_frob;
  2. #pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
  3. %header %{
  4. #include <iostream>
  5. %}
  6. %feature("director");
  7. %feature("nodirector") Bravo::abs_method(); // ok
  8. %feature("director") Charlie::abs_method(); // ok
  9. %feature("nodirector") Delta::abs_method(); // ok
  10. %inline %{
  11. struct Alpha
  12. {
  13. virtual ~Alpha() { };
  14. virtual const char* abs_method() = 0;
  15. };
  16. struct Bravo : Alpha
  17. {
  18. const char* abs_method()
  19. {
  20. return "Bravo::abs_method()";
  21. }
  22. };
  23. struct Charlie : Bravo
  24. {
  25. const char* abs_method()
  26. {
  27. return "Charlie::abs_method()";
  28. }
  29. };
  30. struct Delta : Charlie
  31. {
  32. };
  33. %}
  34. %rename(OpInt) operator int();
  35. %rename(OpIntStarStarConst) operator int **() const;
  36. %rename(OpIntAmp) operator int &();
  37. %rename(OpIntStar) operator void *();
  38. %rename(OpConstIntIntStar) operator const int *();
  39. %inline %{
  40. class Ops {
  41. public:
  42. Ops() : num(0) {}
  43. virtual ~Ops() {}
  44. virtual operator int() { return 0; }
  45. virtual operator int **() const {
  46. return (int **) 0;
  47. }
  48. virtual operator int &() {
  49. return num;
  50. }
  51. virtual operator void *() {
  52. return (void *) this;
  53. }
  54. virtual operator const int *() {
  55. return &num;
  56. }
  57. private:
  58. int num;
  59. };
  60. struct Prims {
  61. virtual ~Prims() {}
  62. virtual unsigned long long ull(unsigned long long i, unsigned long long j) { return i + j; }
  63. unsigned long long callull(int i, int j) { return ull(i, j); }
  64. };
  65. %}
  66. // The similarity of the director class name and other symbol names were causing a problem in the code generation
  67. %feature("director") coreCallbacks;
  68. %inline %{
  69. class corePoint3d {};
  70. struct coreCallbacks_On3dEngineRedrawnData
  71. {
  72. corePoint3d _eye;
  73. corePoint3d _at;
  74. };
  75. struct coreCallbacksOn3dEngineRedrawnData
  76. {
  77. corePoint3d _eye;
  78. corePoint3d _at;
  79. };
  80. class coreCallbacks
  81. {
  82. public:
  83. coreCallbacks(void) {}
  84. virtual ~coreCallbacks(void) {}
  85. virtual void On3dEngineRedrawn(const coreCallbacks_On3dEngineRedrawnData& data){}
  86. virtual void On3dEngineRedrawn2(const coreCallbacksOn3dEngineRedrawnData& data){}
  87. };
  88. %}