summaryrefslogtreecommitdiff
path: root/Lib/d/dclassgen.swg
blob: ceaf5072790dc1f9aa46c9d7f0b8caaceba2721c (plain)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* -----------------------------------------------------------------------------
 * dclassgen.swg
 *
 * Typemaps containing D code used when generating D proxy classes.
 * ----------------------------------------------------------------------------- */

%typemap(dbase)               SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(dclassmodifiers)     SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "class"
%typemap(dcode)               SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(dimports)            SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(dinterfaces)         SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(dinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""

// See <denums.swg>.
%typemap(dclassmodifiers) enum SWIGTYPE "enum"
%typemap(dcode) enum SWIGTYPE ""


/*
 * Proxy classes.
 */

%typemap(dconstructor, excode=SWIGEXCODE,directorconnect="\n  swigDirectorConnect();") SWIGTYPE {
  this($imcall, true);$excode$directorconnect
}

%typemap(ddestructor) SWIGTYPE %{
~this() {
  dispose();
}
%}

// We do not use »override« attribute for generated dispose() methods to stay
// somewhat compatible to Phobos and older Tango versions where Object.dispose()
// does not exist.
%typemap(ddispose, methodname="dispose", methodmodifiers="public") SWIGTYPE {
  synchronized(this) {
    if (swigCPtr !is null) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        $imcall;
      }
      swigCPtr = null;
    }
  }
}

%typemap(ddispose_derived, methodname="dispose", methodmodifiers="public") SWIGTYPE {
  synchronized(this) {
    if (swigCPtr !is null) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        $imcall;
      }
      swigCPtr = null;
      super.dispose();
    }
  }
}


// Unfortunately, the »package« visibility attribute does not work in D when the
// module in question is in the root package (happens if no -package is specified
// at the SWIG command line), so we are stuck with public visibility for
// swigGetCPtr().
%typemap(dbody) SWIGTYPE %{
private void* swigCPtr;
protected bool swigCMemOwn;

public this(void* cObject, bool ownCObject) {
  swigCPtr = cObject;
  swigCMemOwn = ownCObject;
}

public static void* swigGetCPtr($dclassname obj) {
  return (obj is null) ? null : obj.swigCPtr;
}

mixin $imdmodule.SwigOperatorDefinitions;
%}


%typemap(dbody_derived) SWIGTYPE %{
private void* swigCPtr;

public this(void* cObject, bool ownCObject) {
  super($imdmodule.$dclazznameUpcast(cObject), ownCObject);
  swigCPtr = cObject;
}

public static void* swigGetCPtr($dclassname obj) {
  return (obj is null) ? null : obj.swigCPtr;
}

mixin $imdmodule.SwigOperatorDefinitions;
%}


/*
 * Type wrapper classes.
 */

%typemap(dbody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{
private void* swigCPtr;

public this(void* cObject, bool futureUse) {
  swigCPtr = cObject;
}

protected this() {
  swigCPtr = null;
}

public static void* swigGetCPtr($dclassname obj) {
  return (obj is null) ? null : obj.swigCPtr;
}

mixin $imdmodule.SwigOperatorDefinitions;
%}


/*
 * Member function pointer wrapper classes (see <dmemberfunctionpointers.swg>).
 */

%typemap(dbody) SWIGTYPE (CLASS::*) %{
private char* swigCPtr;

public this(char* cMemberPtr, bool futureUse) {
  swigCPtr = cMemberPtr;
}

protected this() {
  swigCPtr = null;
}

package static char* swigGetCMemberPtr($dclassname obj) {
  return (obj is null) ? null : obj.swigCPtr;
}

mixin $imdmodule.SwigOperatorDefinitions;
%}