File: extend_variable.i

package info (click to toggle)
renderdoc 1.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 79,584 kB
  • sloc: cpp: 491,671; ansic: 285,823; python: 12,617; java: 11,345; cs: 7,181; makefile: 6,703; yacc: 5,682; ruby: 4,648; perl: 3,461; php: 2,119; sh: 2,068; lisp: 1,835; tcl: 1,068; ml: 747; xml: 137
file content (103 lines) | stat: -rw-r--r-- 1,382 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
%module extend_variable

// Tests %extend for variables

%inline %{
class ExtendMe {
  double var;
public:
  ExtendMe() : var(0.0) {}
  bool get(double &d) {
    d = var;
    return true;
  }
  bool set(const double &d) {
    var = d;
    return true;
  }
};
%}

%extend ExtendMe {
  double ExtendVar;
};

%{
// If possible, all language modules should use this naming format for consistency
void ExtendMe_ExtendVar_set(ExtendMe *thisptr, double value) {
  thisptr->set(value);
}
double ExtendMe_ExtendVar_get(ExtendMe *thisptr) {
  double value = 0;
  thisptr->get(value);
  return value;
}
%}


%{
  class Foo 
  {
  };
%}

#if SWIGJAVA
%javaconst(1) AllBarOne;
#elif SWIGCSHARP
%csconst(1) AllBarOne;
#endif


class Foo {
  public:
    %extend {
        static const int Bar = 42;
        static const int AllBarOne = 4422;
        static const int StaticConstInt;
        static int StaticInt;
    }
}; 
  
%{
  int globalVariable = 1111;

  void Foo_StaticInt_set(int value) {
    globalVariable = value;
  }

  int Foo_StaticInt_get() {
    return globalVariable;
  }

  int Foo_StaticConstInt_get() {
    static int var = 2222;
    return var;
  }
%}

%inline {
  namespace ns1 
  {
    struct Bar
    {
    }
    ;
  }
}

%{
  int ns1_Bar_x_get(ns1::Bar *self) {
    return 1;
  }

  void ns1_Bar_x_set(ns1::Bar *self, int x) {
  }
%}
  
%extend ns1::Bar 
{
  int x;
}