dclassgen.swg 3.5 KB

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