erwin/classundef.h
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 #ifndef Global_ERWIN_CLASSUNDEF_H
51 #define Global_ERWIN_CLASSUNDEF_H
52
53
54
55
56
57
58
59
60 #undef _Global_member_priv
61 #define _Global_member_priv(TYPE, NAME, DOCSTRING) \
62 private: \
63 TYPE _m_##NAME; \
64 protected: \
65 TYPE &m_##NAME() \
66 { \
67 Global_CHECK_SIG(this); \
68 return _m_##NAME; \
69 } \
70 TYPE const &m_##NAME() const \
71 { \
72 Global_CHECK_SIG(this); \
73 return _m_##NAME; \
74 } \
75 public:
76
77 #undef _Global_member_priv_obj
78 #define _Global_member_priv_obj(TYPE, NAME, DOCSTRING) \
79 private: \
80 TYPE *_m_##NAME; \
81 protected: \
82 TYPE *&m_##NAME() { \
83 Global_CHECK_SIG(this); \
84 Global_CHECK_OTHER_SIG(_m_##NAME); \
85 return _m_##NAME; \
86 } \
87 TYPE *const &m_##NAME() const { \
88 Global_CHECK_SIG(this); \
89 Global_CHECK_OTHER_SIG(_m_##NAME); \
90 return _m_##NAME; \
91 } \
92 public: \
93
94
95 #undef _Global_member_ri_ptr
96 #define _Global_member_ri_ptr(TYPE, NAME, DOCSTRING) \
97 _Global_member_priv_ptr (TYPE, NAME, DOCSTRING) \
98 TYPE *NAME() { \
99 if (this == NULL) return NULL; \
100 return m_##NAME(); \
101 } \
102 TYPE const *NAME() const { \
103 if (this == NULL) return NULL; \
104 return m_##NAME(); \
105 }
106
107 #undef _Global_member_ri_obj
108 #define _Global_member_ri_obj(TYPE, NAME, DOCSTRING) \
109 _Global_member_priv_obj (TYPE, NAME, DOCSTRING) \
110 TYPE *NAME() { \
111 if (this == NULL) return NULL; \
112 return m_##NAME(); \
113 } \
114 TYPE const *NAME() const { \
115 if (this == NULL) return NULL; \
116 return m_##NAME(); \
117 }
118
119
120 #undef _Global_member_ri_ref
121 #define _Global_member_ri_ref(TYPE, NAME, DOCSTRING) \
122 _Global_member_priv_ref (TYPE, NAME, DOCSTRING) \
123 TYPE *NAME() { \
124 if (this == NULL) return NULL; \
125 return &m_##NAME(); \
126 } \
127 TYPE const *NAME() const { \
128 if (this == NULL) return NULL; \
129 return &m_##NAME(); \
130 }
131
132 #undef _Global_member_ri_eref
133 #define _Global_member_ri_eref(TYPE, NAME, DOCSTRING) \
134 _Global_member_priv_eref (TYPE, NAME, DOCSTRING) \
135 TYPE &NAME() { \
136 assert (this != NULL); \
137 return m_##NAME(); \
138 } \
139 TYPE const &NAME() const { \
140 assert (this != NULL); \
141 return m_##NAME(); \
142 }
143
144
145 #undef _Global_member_ro
146 #define _Global_member_ro(TYPE, NAME, DOCSTRING) \
147 _Global_member_priv (TYPE, NAME, DOCSTRING) \
148 TYPE NAME() const { \
149 assert (this != NULL); \
150 return m_##NAME(); \
151 }
152
153
154
155
156
157 #undef _Global_member_ro_ref
158 #define _Global_member_ro_ref(TYPE, NAME, DOCSTRING) \
159 _Global_member_priv_ref (TYPE, NAME, DOCSTRING) \
160 TYPE const *NAME() const { \
161 if (this == NULL) return NULL; \
162 return &m_##NAME(); \
163 }
164
165
166 #undef _Global_member_ro_eref
167 #define _Global_member_ro_eref(TYPE, NAME, DOCSTRING) \
168 _Global_member_priv_eref (TYPE, NAME, DOCSTRING) \
169 TYPE const &NAME() const { \
170 assert (this != NULL); \
171 return m_##NAME(); \
172 }
173
174
175
176 #undef _Global_member_ro_ptr
177 #define _Global_member_ro_ptr(TYPE, NAME, DOCSTRING) \
178 _Global_member_priv_ptr (TYPE, NAME, DOCSTRING) \
179 TYPE *NAME() const { \
180 if (this == NULL) return NULL; \
181 return m_##NAME(); \
182 }
183
184 #undef _Global_member_ro_obj
185 #define _Global_member_ro_obj(TYPE, NAME, DOCSTRING) \
186 _Global_member_priv_obj (TYPE, NAME, DOCSTRING) \
187 TYPE *NAME() const { \
188 if (this == NULL) return NULL; \
189 return m_##NAME(); \
190 }
191
192
193 #undef _Global_member_rw
194 #define _Global_member_rw(TYPE, NAME, DOCSTRING) \
195 _Global_member_priv (TYPE, NAME, DOCSTRING) \
196 TYPE NAME() const { \
197 assert (this != NULL); \
198 return m_##NAME(); \
199 } \
200 void set_##NAME (TYPE a) { \
201 assert (this != NULL); \
202 m_##NAME()= a; \
203 }
204
205 #undef _Global_member_rw_ref
206 #define _Global_member_rw_ref(TYPE, NAME, DOCSTRING) \
207 _Global_member_priv_ref (TYPE, NAME, DOCSTRING) \
208 TYPE *NAME() { \
209 if (this == NULL) return NULL; \
210 return &m_##NAME(); \
211 } \
212 TYPE const *NAME() const { \
213 if (this == NULL) return NULL; \
214 return &m_##NAME(); \
215 } \
216 void set_##NAME (TYPE const *a) { \
217 assert (this != NULL); \
218 m_##NAME()= *a; \
219 }
220
221 #undef _Global_member_rw_eref
222 #define _Global_member_rw_eref(TYPE, NAME, DOCSTRING) \
223 _Global_member_priv_eref (TYPE, NAME, DOCSTRING) \
224 TYPE &NAME() { \
225 assert (this != NULL); \
226 return m_##NAME(); \
227 } \
228 TYPE const &NAME() const { \
229 assert (this != NULL); \
230 return &m_##NAME(); \
231 } \
232 void set_##NAME (TYPE const &a) { \
233 assert (this != NULL); \
234 assert (&a != NULL); \
235 m_##NAME()= a; \
236 }
237
238 #undef _Global_member_rw_ptr
239 #define _Global_member_rw_ptr(TYPE, NAME, DOCSTRING) \
240 _Global_member_priv_ptr (TYPE, NAME, DOCSTRING) \
241 TYPE *NAME() const { \
242 if (this == NULL) return NULL; \
243 return m_##NAME(); \
244 } \
245 void set_##NAME (TYPE *a) { \
246 assert (this != NULL); \
247 m_##NAME()= a; \
248 } \
249 void reset_##NAME () { \
250 set_##NAME ((TYPE *)NULL); \
251 }
252
253 #undef _Global_member_rw_obj
254 #define _Global_member_rw_obj(TYPE, NAME, DOCSTRING) \
255 _Global_member_priv_obj (TYPE, NAME, DOCSTRING) \
256 TYPE *NAME() const { \
257 if (this == NULL) return NULL; \
258 return m_##NAME(); \
259 } \
260 void set_##NAME (TYPE *a) { \
261 assert (this != NULL); \
262 Global_REF ((GlobalUCFirst_Object *)a); \
263 Global_CHECK_OTHER_SIG(a); \
264 Global_UNREF_RVAL((GlobalUCFirst_Object *)m_##NAME()); \
265 _m_##NAME= a; \
266 } \
267 void reset_##NAME () { \
268 Global_UNREF_RVAL((GlobalUCFirst_Object *)m_##NAME()); \
269 _m_##NAME= NULL; \
270 }
271
272
273 #undef _Global_member_rp
274 #define _Global_member_rp(TYPE, NAME, DOCSTRING) \
275 _Global_member_priv (TYPE, NAME, DOCSTRING) \
276 TYPE NAME() const { \
277 assert (this != NULL); \
278 return m_##NAME(); \
279 } \
280 protected: \
281 void set_##NAME (TYPE a) { \
282 assert (this != NULL); \
283 m_##NAME()= a; \
284 } \
285 public:
286
287 #undef _Global_member_rp_ref
288 #define _Global_member_rp_ref(TYPE, NAME, DOCSTRING) \
289 _Global_member_priv_ref (TYPE, NAME, DOCSTRING) \
290 TYPE const *NAME() const { \
291 if (this == NULL) return NULL; \
292 return &m_##NAME(); \
293 } \
294 protected: \
295 TYPE *NAME() { \
296 if (this == NULL) return NULL; \
297 return &m_##NAME(); \
298 } \
299 void set_##NAME (TYPE const *a) { \
300 assert (this != NULL); \
301 m_##NAME()= *a; \
302 } \
303 public:
304
305 #undef _Global_member_rp_eref
306 #define _Global_member_rp_eref(TYPE, NAME, DOCSTRING) \
307 _Global_member_priv_eref (TYPE, NAME, DOCSTRING) \
308 TYPE const &NAME() const { \
309 assert (this != NULL); \
310 return &m_##NAME(); \
311 } \
312 protected: \
313 TYPE &NAME() { \
314 assert (this != NULL); \
315 return m_##NAME(); \
316 } \
317 void set_##NAME (TYPE const &a) { \
318 assert (this != NULL); \
319 assert (&a != NULL); \
320 m_##NAME()= a; \
321 } \
322 public:
323
324 #undef _Global_member_rp_ptr
325 #define _Global_member_rp_ptr(TYPE, NAME, DOCSTRING) \
326 _Global_member_priv_ptr (TYPE, NAME, DOCSTRING) \
327 TYPE *NAME() const { \
328 if (this == NULL) return NULL; \
329 return m_##NAME(); \
330 } \
331 protected: \
332 void set_##NAME (TYPE *a) { \
333 assert (this != NULL); \
334 m_##NAME()= a; \
335 } \
336 void reset_##NAME () { \
337 set_##NAME ((TYPE *)NULL); \
338 } \
339 public:
340
341 #undef _Global_member_rp_obj
342 #define _Global_member_rp_obj(TYPE, NAME, DOCSTRING) \
343 _Global_member_priv_obj (TYPE, NAME, DOCSTRING) \
344 TYPE *NAME() const { \
345 if (this == NULL) return NULL; \
346 return m_##NAME(); \
347 } \
348 protected: \
349 void set_##NAME (TYPE *a) { \
350 assert (this != NULL); \
351 Global_REF ((GlobalUCFirst_Object *)a); \
352 Global_CHECK_OTHER_SIG(a); \
353 Global_UNREF_RVAL((GlobalUCFirst_Object *)m_##NAME()); \
354 _m_##NAME= a; \
355 } \
356 void reset_##NAME () { \
357 Global_UNREF_RVAL((GlobalUCFirst_Object *)m_##NAME()); \
358 _m_##NAME= NULL; \
359 } \
360 public:
361
362 #undef Global_stdclass_no_ref
363 #define Global_stdclass_no_ref \
364 public: \
365 typedef THIS This; \
366 typedef SUPER Super; \
367 protected: \
368 virtual THIS *ERWIN_CONCAT_TOKEN(v_as_, THIS) () {Global_CHECK_SIG(this); return this; } \
369 public:
370
371
372 #undef Global_stdclass
373 #define Global_stdclass \
374 Global_stdclass_no_ref \
375 public: \
376 Global_stdclass_refcount \
377 public:
378
379
380 #undef Global_concrete
381 #define Global_concrete \
382 Global_stdclass \
383 private: \
384 virtual void _concrete () const { } \
385 protected: \
386 virtual char const *v_klass_name() const { return ERWIN_STR(THIS); } \
387 Global_concrete_id \
388 public:
389
390
391 #undef Global_abstract
392 #define Global_abstract \
393 Global_stdclass \
394 private: \
395 virtual void _concrete () const = 0; \
396 protected: \
397 virtual char const *v_klass_name() const = 0; \
398 Global_abstract_id \
399 public:
400
401 #undef Global_abstract_no_ref
402 #define Global_abstract_no_ref \
403 Global_stdclass_no_ref \
404 private: \
405 virtual void _concrete () const = 0; \
406 protected: \
407 virtual char const *v_klass_name() const = 0; \
408 Global_abstract_id \
409 public:
410
411
412 #ifndef NDEBUG
413
414 # undef Global_make_cast
415 # define Global_make_cast(TYPE) \
416 public: \
417 TYPE *cast_##TYPE () { \
418 if (this == NULL) return NULL; \
419 TYPE *ERWIN_GENSYM(local_result)= as_##TYPE(); \
420 assert (ERWIN_GENSYM(local_result) != NULL); \
421 return ERWIN_GENSYM(local_result); \
422 } \
423 TYPE const *cast_##TYPE () const { \
424 if (this == NULL) return NULL; \
425 TYPE const *ERWIN_GENSYM(local_result)= as_##TYPE(); \
426 assert (ERWIN_GENSYM(local_result) != NULL); \
427 return ERWIN_GENSYM(local_result); \
428 }
429
430 #else
431
432 # undef Global_make_cast
433 # define Global_make_cast(TYPE) \
434 public: \
435 TYPE *cast_##TYPE () { \
436 return (TYPE *)this; \
437 } \
438 TYPE const *cast_##TYPE () const { \
439 return (TYPE const *)this; \
440 }
441
442 #endif
443
444 #undef Global_announce_class
445 #define Global_announce_class(TYPE) \
446 protected: \
447 virtual TYPE *v_as_##TYPE() { return NULL; } \
448 Global_make_cast(TYPE) \
449 public: \
450 TYPE *as_##TYPE () { \
451 if (this == NULL) return NULL; \
452 return v_as_##TYPE(); \
453 } \
454 TYPE const *as_##TYPE () const { \
455 if (this == NULL) return NULL; \
456 return ((Object *)this)->v_as_##TYPE(); \
457 }
458
459 #endif
460
461
462
463
464
465
466
467 --WITH-GLOBAL--#undef child_priv
468 --WITH-GLOBAL--#undef child_priv_ref
469 --WITH-GLOBAL--#undef child_priv_eref
470 --WITH-GLOBAL--#undef child_priv_ptr
471 --WITH-GLOBAL--#undef child_priv_obj
472 --WITH-GLOBAL--#undef child_ri_obj
473 --WITH-GLOBAL--#undef child_ri_ptr
474 --WITH-GLOBAL--#undef child_ri_ref
475 --WITH-GLOBAL--#undef child_ri_eref
476 --WITH-GLOBAL--#undef child_ro
477 --WITH-GLOBAL--#undef child_ro_obj
478 --WITH-GLOBAL--#undef child_ro_ptr
479 --WITH-GLOBAL--#undef child_ro_ref
480 --WITH-GLOBAL--#undef child_ro_eref
481 --WITH-GLOBAL--#undef child_rw
482 --WITH-GLOBAL--#undef child_rw_obj
483 --WITH-GLOBAL--#undef child_rw_ptr
484 --WITH-GLOBAL--#undef child_rw_ref
485 --WITH-GLOBAL--#undef child_rw_eref
486 --WITH-GLOBAL--#undef child_rp
487 --WITH-GLOBAL--#undef child_rp_obj
488 --WITH-GLOBAL--#undef child_rp_ptr
489 --WITH-GLOBAL--#undef child_rp_ref
490 --WITH-GLOBAL--#undef child_rp_eref
491 --WITH-GLOBAL--#undef xref_priv_obj
492 --WITH-GLOBAL--#undef xref_priv_ptr
493 --WITH-GLOBAL--#undef xref_ri_obj
494 --WITH-GLOBAL--#undef xref_ri_ptr
495 --WITH-GLOBAL--#undef xref_ro_obj
496 --WITH-GLOBAL--#undef xref_ro_ptr
497 --WITH-GLOBAL--#undef xref_rw_obj
498 --WITH-GLOBAL--#undef xref_rw_ptr
499 --WITH-GLOBAL--#undef xref_rp_obj
500 --WITH-GLOBAL--#undef xref_rp_ptr
501
502 --WITH-GLOBAL--#undef stdclass
503 --WITH-GLOBAL--#undef stdclass_no_ref
504 --WITH-GLOBAL--#undef concrete
505 --WITH-GLOBAL--#undef abstract
506 --WITH-GLOBAL--#undef abstract_no_ref
507 --WITH-GLOBAL--#undef general_object
508
509 --WITH-GLOBAL--#undef announce_class
510
511 --WITH-GLOBAL--#undef hidden
512 --WITH-GLOBAL--#undef trivial
513 --WITH-GLOBAL--#undef redirect
514 --WITH-GLOBAL--#undef inherit
515
516 --WITH-GLOBAL--#undef foreign_class
517 --WITH-GLOBAL--#undef foreign_type
518 --WITH-GLOBAL--#undef local_class
519 --WITH-GLOBAL--#undef local_type
520 --WITH-GLOBAL--#undef local_enum
521 --WITH-GLOBAL--#undef local_union
522