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