1/* ----------------------------------------------------------------------------- 2 * dclassgen.swg 3 * 4 * Typemaps containing D code used when generating D proxy classes. 5 * ----------------------------------------------------------------------------- */ 6 7%typemap(dbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" 8%typemap(dclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "class" 9%typemap(dcode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" 10%typemap(dimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" 11%typemap(dinterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" 12%typemap(dinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "" 13 14// See <denums.swg>. 15%typemap(dclassmodifiers) enum SWIGTYPE "enum" 16%typemap(dcode) enum SWIGTYPE "" 17 18 19/* 20 * Proxy classes. 21 */ 22 23%typemap(dconstructor, excode=SWIGEXCODE,directorconnect="\n swigDirectorConnect();") SWIGTYPE { 24 this($imcall, true);$excode$directorconnect 25} 26 27%typemap(ddestructor) SWIGTYPE %{ 28~this() { 29 dispose(); 30} 31%} 32 33// We do not use »override« attribute for generated dispose() methods to stay 34// somewhat compatible to Phobos and older Tango versions where Object.dispose() 35// does not exist. 36%typemap(ddispose, methodname="dispose", methodmodifiers="public") SWIGTYPE { 37 synchronized(this) { 38 if (swigCPtr !is null) { 39 if (swigCMemOwn) { 40 swigCMemOwn = false; 41 $imcall; 42 } 43 swigCPtr = null; 44 } 45 } 46} 47 48%typemap(ddispose_derived, methodname="dispose", methodmodifiers="public") SWIGTYPE { 49 synchronized(this) { 50 if (swigCPtr !is null) { 51 if (swigCMemOwn) { 52 swigCMemOwn = false; 53 $imcall; 54 } 55 swigCPtr = null; 56 super.dispose(); 57 } 58 } 59} 60 61 62// Unfortunately, the »package« visibility attribute does not work in D when the 63// module in question is in the root package (happens if no -package is specified 64// at the SWIG command line), so we are stuck with public visibility for 65// swigGetCPtr(). 66%typemap(dbody) SWIGTYPE %{ 67private void* swigCPtr; 68protected bool swigCMemOwn; 69 70public this(void* cObject, bool ownCObject) { 71 swigCPtr = cObject; 72 swigCMemOwn = ownCObject; 73} 74 75public static void* swigGetCPtr($dclassname obj) { 76 return (obj is null) ? null : obj.swigCPtr; 77} 78 79mixin $imdmodule.SwigOperatorDefinitions; 80%} 81 82 83%typemap(dbody_derived) SWIGTYPE %{ 84private void* swigCPtr; 85 86public this(void* cObject, bool ownCObject) { 87 super($imdmodule.$dclazznameUpcast(cObject), ownCObject); 88 swigCPtr = cObject; 89} 90 91public static void* swigGetCPtr($dclassname obj) { 92 return (obj is null) ? null : obj.swigCPtr; 93} 94 95mixin $imdmodule.SwigOperatorDefinitions; 96%} 97 98 99/* 100 * Type wrapper classes. 101 */ 102 103%typemap(dbody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{ 104private void* swigCPtr; 105 106public this(void* cObject, bool futureUse) { 107 swigCPtr = cObject; 108} 109 110protected this() { 111 swigCPtr = null; 112} 113 114public static void* swigGetCPtr($dclassname obj) { 115 return (obj is null) ? null : obj.swigCPtr; 116} 117 118mixin $imdmodule.SwigOperatorDefinitions; 119%} 120 121 122/* 123 * Member function pointer wrapper classes (see <dmemberfunctionpointers.swg>). 124 */ 125 126%typemap(dbody) SWIGTYPE (CLASS::*) %{ 127private char* swigCPtr; 128 129public this(char* cMemberPtr, bool futureUse) { 130 swigCPtr = cMemberPtr; 131} 132 133protected this() { 134 swigCPtr = null; 135} 136 137package static char* swigGetCMemberPtr($dclassname obj) { 138 return (obj is null) ? null : obj.swigCPtr; 139} 140 141mixin $imdmodule.SwigOperatorDefinitions; 142%} 143