PageRenderTime 34ms CodeModel.GetById 31ms app.highlight 1ms RepoModel.GetById 1ms 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
 1
 2%module(directors="1") director_extend
 3
 4%extend SpObject 
 5{
 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
15namespace 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{
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 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 %{
39class SpObject
40{
41public:
42   SpObject() {}
43   virtual ~SpObject() {}
44
45   int getFooBar() const {
46      return 666;
47   }
48
49private:
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