~jtaylor/ubuntu/natty/pyfltk/fix-779340

« back to all changes in this revision

Viewing changes to swig/macros.i

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2009-03-13 20:47:00 UTC
  • Revision ID: james.westby@ubuntu.com-20090313204700-ra4hgdlhxzrccas3
Tags: upstream-1.1.3
ImportĀ upstreamĀ versionĀ 1.1.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// macro to delegate the ownership of a class to C++
 
2
%define CHANGE_OWNERSHIP(name)
 
3
%pythonappend name##::##name %{
 
4
        if len(args) == 6:
 
5
            # retain reference to label
 
6
            self.my_label = args[5]
 
7
        if self.parent() != None:
 
8
                # delegate ownership to C++
 
9
            self.this.disown()
 
10
%}
 
11
%enddef
 
12
 
 
13
// macro to revert the ownership
 
14
%define REVERT_OWNERSHIP(name)
 
15
%pythonappend name %{
 
16
        self = args[0]
 
17
        if self.parent() != None:
 
18
            #delegate ownership to C++
 
19
            self.this.disown()
 
20
        else:
 
21
            #give ownership back to Python
 
22
            self.this.own() 
 
23
%}
 
24
%enddef
 
25