oo_DESTROY.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* oo_DESTROY.h
  2. *
  3. * Copyright (C) 1994-2007,2009-2018 Paul Boersma
  4. *
  5. * This code is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This code is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. * See the GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "oo_undef.h"
  19. #define oo_SIMPLE(type, storage, x)
  20. #define oo_SET(type, storage, x, setType)
  21. #define oo_VECTOR(type, storage, x, min, max) \
  22. { \
  23. integer _min = (min); \
  24. NUMvector_free <type> (our x, _min); \
  25. }
  26. #define oo_ANYVEC(type, storage, x, sizeExpression) \
  27. if (! _thisStructCanAutodestroyItsMembers_) { \
  28. our x. reset (); \
  29. }
  30. #define oo_MATRIX(type, storage, x, row1, row2, col1, col2) \
  31. { \
  32. integer _row1 = (row1), _col1 = (col1); \
  33. NUMmatrix_free <type> (our x, _row1, _col1); \
  34. }
  35. #define oo_ANYMAT(type, storage, x, nrowExpression, ncolExpression) \
  36. if (! _thisStructCanAutodestroyItsMembers_) { \
  37. our x. reset (); \
  38. }
  39. #define oo_ENUMx(kType, storage, x)
  40. //#define oo_ENUMx_SET(kType, storage, x, setType)
  41. //#define oo_ENUMx_VECTOR(kType, storage, x, min, max) \
  42. // { \
  43. // integer _min = (min); \
  44. // NUMvector_free <type> (our x, _min); \
  45. // }
  46. #define oo_STRINGx(storage, x) \
  47. if (! _thisStructCanAutodestroyItsMembers_) { \
  48. our x. reset (); \
  49. }
  50. #define oo_STRINGx_SET(storage, x, setType) \
  51. if (! _thisStructCanAutodestroyItsMembers_) { \
  52. for (int _i = 0; _i <= setType::MAX; _i ++) { \
  53. our x [_i]. reset (); \
  54. } \
  55. }
  56. #define oo_STRINGx_VECTOR(storage, x, n) \
  57. if (! _thisStructCanAutodestroyItsMembers_) { \
  58. our x. reset (); \
  59. }
  60. #define oo_STRUCT(Type, x) \
  61. our x. destroy ();
  62. #define oo_STRUCT_SET(Type, x, setType) \
  63. for (int _i = 0; _i <= (int) setType::MAX; _i ++) { \
  64. our x [_i]. destroy (); \
  65. }
  66. #define oo_STRUCT_VECTOR_FROM(Type, x, min, max) \
  67. { \
  68. integer _min = (min), _max = (max); \
  69. if (our x) { \
  70. for (integer _i = _min; _i <= _max; _i ++) { \
  71. our x [_i]. destroy (); \
  72. } \
  73. NUMvector_free <struct##Type> (our x, _min); \
  74. } \
  75. }
  76. #define oo_STRUCT_MATRIX_FROM(Type, x, row1, row2, col1, col2) \
  77. { \
  78. integer _row1 = (row1), _row2 = (row2), _col1 = (col1), _col2 = (col2); \
  79. if (our x) { \
  80. for (integer _irow = _row1; _irow <= _row2; _irow ++) { \
  81. for (integer _icol = _col1; _icol <= _col2; _icol ++) { \
  82. our x [_irow] [_icol]. destroy (); \
  83. } \
  84. } \
  85. NUMmatrix_free <struct##Type> (our x, _row1, _col1); \
  86. } \
  87. }
  88. #define oo_OBJECT(Class, version, x) \
  89. if (! _thisStructCanAutodestroyItsMembers_) { \
  90. x. reset (); \
  91. }
  92. #define oo_COLLECTION_OF(Class, x, ItemClass, version)
  93. #define oo_COLLECTION(Class, x, ItemClass, version)
  94. #define oo_FILE(x)
  95. #define oo_DIR(x)
  96. #define oo_DEFINE_STRUCT(Struct) \
  97. void struct##Struct :: destroy () { \
  98. constexpr bool _thisStructCanAutodestroyItsMembers_ = false; \
  99. (void) _thisStructCanAutodestroyItsMembers_;
  100. #define oo_END_STRUCT(Type) \
  101. }
  102. #define oo_DEFINE_CLASS(Class, Parent) \
  103. void struct##Class :: v_destroy () noexcept { \
  104. constexpr bool _thisStructCanAutodestroyItsMembers_ = true; \
  105. (void) _thisStructCanAutodestroyItsMembers_;
  106. #define oo_END_CLASS(Class) \
  107. Class##_Parent :: v_destroy (); \
  108. }
  109. #define oo_FROM(from)
  110. #define oo_ENDFROM
  111. #define oo_DECLARING 0
  112. #define oo_DESTROYING 1
  113. #define oo_COPYING 0
  114. #define oo_COMPARING 0
  115. #define oo_VALIDATING_ENCODING 0
  116. #define oo_READING 0
  117. #define oo_READING_TEXT 0
  118. #define oo_READING_BINARY 0
  119. #define oo_WRITING 0
  120. #define oo_WRITING_TEXT 0
  121. #define oo_WRITING_BINARY 0
  122. #define oo_DESCRIBING 0
  123. /* End of file oo_DESTROY.h */