~ubuntu-branches/ubuntu/maverick/swig1.3/maverick

« back to all changes in this revision

Viewing changes to Examples/test-suite/director_classic.i

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2006-12-20 14:43:24 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20061220144324-bps3kb06xp5oy9w1
Tags: 1.3.31-1ubuntu1
* Merge from debian unstable, remaining changes:
  - drop support for pike
  - use php5 instead of php4
  - clean Runtime/ as well
  - force a few environment variables

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%module(directors="1") director_classic
 
2
 
 
3
%include "std_string.i"
 
4
 
 
5
%feature("director");
 
6
 
 
7
%inline %{
 
8
 
 
9
#include <cstdio>
 
10
#include <iostream>
 
11
#include <string>
 
12
 
 
13
struct Being {
 
14
  virtual std::string id() { return "Being"; }
 
15
  virtual ~Being() {}
 
16
};
 
17
 
 
18
struct Person : Being {
 
19
  virtual std::string id() { return "Person"; }
 
20
};
 
21
 
 
22
struct Child : Person {
 
23
  virtual std::string id() { return "Child"; }
 
24
};
 
25
 
 
26
struct GrandChild : Child {
 
27
  virtual std::string id() { return "GrandChild"; }
 
28
};
 
29
 
 
30
// Orphans - don't override id() in C++
 
31
struct OrphanPerson : Person {
 
32
  // no overridden id()
 
33
};
 
34
 
 
35
struct OrphanChild : Child {
 
36
  // no overridden id()
 
37
};
 
38
 
 
39
class Caller {
 
40
private:
 
41
  Person *_callback;
 
42
public:
 
43
  Caller(): _callback(0) {}
 
44
  ~Caller() { delCallback(); }
 
45
  void delCallback() { delete _callback; _callback = 0; }
 
46
  void setCallback(Person *cb) { delCallback(); _callback = cb; }
 
47
  void resetCallback() { _callback = 0; }
 
48
  std::string call() { if (_callback) return _callback->id(); else return "oops";  }
 
49
  Person* baseClass() { return _callback; }
 
50
};
 
51
 
 
52
%}
 
53