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