Debian Codegraph @

sys/oo_COPY.h

raw symbols SCIP
1 /* oo_COPY.h
2 *
3 * Copyright (C) 1994-2007,2009,2011-2020,2022,2024,2026 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 3 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
19 #include "oo_undef.h"
20
21 #define oo_SIMPLE(type, storage, x) \
22 thy x = our x;
23
24 #define oo_SET(type, storage, x, setType) \
25 for (int _i = 0; _i <= (int) setType::MAX; _i ++) { \
26 thy x [_i] = our x [_i]; \
27 }
28
29 #define oo_ANYVEC(type, storage, x, sizeExpression) \
30 thy x = newvectorcopy (our x.all());
31
32 #define oo_ANYMAT(type, storage, x, nrowExpression, ncolExpression) \
33 thy x = newmatrixcopy (our x.all());
34
35 #define oo_ANYTEN3(type, storage, x, ndim1Expression, ndim2Expression, ndim3Expression) \
36 thy x = newtensor3copy (our x.get());
37
38 #define oo_ENUMx(kType, storage, x) \
39 thy x = our x;
40
41 //#define oo_ENUMx_SET(kType, storage, x, setType) \
42 // for (int _i = 0; _i <= (int) setType::MAX; _i ++) \
43 // thy x [_i] = our x [_i];
44
45 #define oo_STRINGx(storage, x) \
46 if (our x) \
47 thy x = Melder_dup (our x.get());
48
49 #define oo_STRINGx_SET(storage, x, setType) \
50 for (int _i = 0; _i <= setType::MAX; _i ++) { \
51 if (our x [_i]) \
52 thy x [_i] = Melder_dup (our x [_i].get()); \
53 }
54
55 #define oo_STRINGx_VECTOR(storage, x, sizeExpression) \
56 { \
57 const integer _size = (sizeExpression); \
58 Melder_assert (_size == our x.size); \
59 if (our x) { \
60 thy x = autoSTRVEC (_size); \
61 for (integer _i = 1; _i <= _size; _i ++) { \
62 if (our x [_i]) \
63 thy x [_i] = Melder_dup (our x [_i].get()); \
64 } \
65 } \
66 }
67
68 #define oo_STRUCT(Type, x) \
69 our x. copy (& thy x);
70
71 #define oo_STRUCT_SET(Type, x, setType) \
72 for (int _i = 0; _i <= (int) setType::MAX; _i ++) { \
73 our x [_i]. copy (& thy x [_i]); \
74 }
75
76 #define oo_STRUCTVEC(Type, x, sizeExpression) \
77 { \
78 const integer _size = (sizeExpression); \
79 Melder_assert (_size == our x.size); \
80 if (_size > 0) { \
81 thy x = newvectorzero <struct##Type> (_size); \
82 for (integer _i = 1; _i <= _size; _i ++) { \
83 our x [_i]. copy (& thy x [_i]); \
84 } \
85 } \
86 }
87
88 #define oo_STRUCTMAT(Type, x, nrowExpression, ncolExpression) \
89 { \
90 const integer _nrow = (nrowExpression), _ncol = (nrowExpression); \
91 Melder_assert (_nrow == our x.nrow && _ncol == our x.ncol); \
92 if (_nrow > 0 && _ncol > 0) { \
93 thy x = newmatrixzero <struct##Type> (_nrow, _ncol); \
94 for (integer _irow = 1; _irow <= _nrow; _irow ++) { \
95 for (integer _icol = 1; _icol <= _ncol; _icol ++) { \
96 our x [_irow] [_icol]. copy (& thy x [_irow] [_icol]); \
97 } \
98 } \
99 } \
100 }
101
102 #define oo_OBJECT(Class, version, x) \
103 if (our x) \
104 thy x = Data_copy (our x.get());
105
106 #define oo_COLLECTION_OF(Class, x, ItemClass, version) \
107 if (our x._capacity > 0) { \
108 thy x.at._elements = Melder_calloc (ItemClass, our x._capacity); \
109 thy x.at._elements --; \
110 } \
111 thy x.size = our x.size; \
112 thy x._capacity = our x._capacity; \
113 thy x._ownItems = our x._ownItems; \
114 thy x._ownershipInitialized = our x._ownershipInitialized; \
115 for (integer _i = 1; _i <= our x.size; _i ++) { \
116 if (our x.at [_i]) \
117 thy x.at [_i] = Data_copy (our x.at [_i]).releaseToAmbiguousOwner(); \
118 }
119
120 #define oo_COLLECTION(Class, x, ItemClass, version) \
121 if (our x) \
122 thy x = Data_copy (our x.get());
123
124 #define oo_TRANSIENT_FILE(x) \
125 MelderFile_copy (& our x, & thy x);
126
127 #define oo_TRANSIENT_FOLDER(x) \
128 MelderFolder_copy (& our x, & thy x);
129
130 #define oo_UNSAFE_BORROWED_TRANSIENT_CONST_OBJECT_REFERENCE(Class, x) \
131 thy x = our x; // reference copy
132
133 #define oo_UNSAFE_BORROWED_TRANSIENT_MUTABLE_OBJECT_REFERENCE(Class, x) \
134 thy x = our x; // reference copy
135
136 #define oo_DEFINE_STRUCT(Type) \
137 void struct##Type :: copy (Type thee) const {
138
139 #define oo_END_STRUCT(Type) \
140 }
141
142 #define oo_DEFINE_CLASS(Class, Parent) \
143 void struct##Class :: v1_copy (Daata _thee_Daata) const { \
144 Class thee = static_cast <Class> (_thee_Daata); \
145 Class##_Parent :: v1_copy (thee);
146
147 #define oo_END_CLASS(Class) \
148 }
149
150 #define oo_FROM(from)
151
152 #define oo_ENDFROM
153
154 #define oo_DECLARING 0
155 #define oo_DESTROYING 0
156 #define oo_COPYING 1
157 #define oo_COMPARING 0
158 #define oo_VALIDATING_ENCODING 0
159 #define oo_READING 0
160 #define oo_READING_TEXT 0
161 #define oo_READING_BINARY 0
162 #define oo_WRITING 0
163 #define oo_WRITING_TEXT 0
164 #define oo_WRITING_BINARY 0
165 #define oo_DESCRIBING 0
166
167 /* End of file oo_COPY.h */