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

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

#
Swig | 57 lines | 47 code | 10 blank | 0 comment | 0 complexity | 697ecede26d4d2b376a14b9c61360bdb MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module(directors="1") director_extend
  2. %extend SpObject
  3. {
  4. virtual int dummy() // Had to remove virtual to work
  5. {
  6. return $self->getFooBar();
  7. }
  8. };
  9. %inline %{
  10. #ifndef SWIG_DIRECTORS
  11. // dummy definition for non-director languages
  12. namespace Swig {
  13. typedef int Director;
  14. }
  15. #endif
  16. %}
  17. // Some director implementations do not have Swig::director
  18. #if !defined(SWIGGO)
  19. %extend SpObject
  20. {
  21. size_t ExceptionMethod()
  22. {
  23. // Check positioning of director code in wrapper file
  24. // Below is what we really want to test, but director exceptions vary too much across across all languages
  25. // throw Swig::DirectorException("DirectorException was not in scope!!");
  26. // Instead check definition of Director class as that is defined in the same place as DirectorException (director.swg)
  27. size_t size = sizeof(Swig::Director);
  28. return size;
  29. }
  30. }
  31. #endif
  32. %inline %{
  33. class SpObject
  34. {
  35. public:
  36. SpObject() {}
  37. virtual ~SpObject() {}
  38. int getFooBar() const {
  39. return 666;
  40. }
  41. private:
  42. // Do NOT define the assignment operator
  43. SpObject& operator=(const SpObject& rhs);
  44. // This class can not be copied. Do NOT define the copy Constructor.
  45. SpObject (const SpObject& rhs);
  46. };
  47. %}