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

« back to all changes in this revision

Viewing changes to Examples/test-suite/python/nondynamic.i

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-09-01 18:35:55 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050901183555-eq59uwhq8b62e44c
Tags: 1.3.24-1ubuntu4
* Use php5-dev instead of php4-dev, to kick php4 out of main.
* Drop support for generation of pike bindings, as nothing uses it,
  and swig is the only thing keeping pike7.6 in main (Ubuntu #13796)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%module nondynamic
 
2
 
 
3
/*
 
4
 Use the "static" feature to make the wrapped class a static one,
 
5
 ie, a python class that doesn't dynamically add new attributes.
 
6
 Hence, for the class
 
7
 
 
8
  %feature("static") A;
 
9
  struct A 
 
10
  {
 
11
    int a;
 
12
    int b;
 
13
  };
 
14
 
 
15
 you will get:
 
16
 
 
17
  aa = A()
 
18
  aa.a = 1  # Ok
 
19
  aa.b = 1  # Ok
 
20
  aa.c = 3  # error
 
21
 
 
22
 Since "static" is a feature, if you use
 
23
 
 
24
  %feature("static");
 
25
 
 
26
 it will make all the wrapped class static ones.
 
27
 
 
28
 The implementation is based on the recipe:
 
29
 
 
30
   http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158
 
31
 
 
32
 and works for modern (-modern) and plain python.
 
33
 
 
34
*/
 
35
 
 
36
 
 
37
 
 
38
//%pythonnondynamic(1);
 
39
%pythonnondynamic(1) A;
 
40
%pythondynamic(1) C;
 
41
 
 
42
 
 
43
%inline %{
 
44
 
 
45
  struct A 
 
46
  {
 
47
    int a;
 
48
    int b;
 
49
  };
 
50
 
 
51
 
 
52
  struct C
 
53
  {
 
54
    int a;
 
55
    int b;
 
56
  };
 
57
 
 
58
%}
 
59