erwin/classdef.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_CLASSDEF_H
51 #define Global_ERWIN_CLASSDEF_H
52
53 #ifdef Global_ERWIN_COMPILING
54 # include "--INCPREF2B--erwin/defs.h"
55 #else
56 # include <--INCPREF2B--erwin/defs.h>
57 #endif
58
59
60
61
62
63
64
65
66
67 #define ?Global_ERWIN_CLASS_REFCOUNT 1
68
69
70
71
72
73
74
75
76 #define ?Global_ERWIN_CLASS_REFCOUNT_FAKE 0
77
78
79
80
81
82
83 #define ?Global_ERWIN_CLASS_ID 1
84
85
86
87
88
89
90
91
92
93
94
95
96
97 #define ?Global_ERWIN_CLASS_USE_CGEN 1
98
99 #ifdef Global_ERWIN_COMPILING
100 # include "--INCPREF2B--erwin/newdelete.h"
101 #else
102 # include <--INCPREF2B--erwin/newdelete.h>
103 #endif
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232 #define _Global_member_priv(TYPE, NAME, DOCSTRING) \
233 private: \
234 TYPE _m_##NAME; \
235 protected: \
236 TYPE &m_##NAME(); \
237 TYPE const &m_##NAME() const; \
238 public:
239
240 #define _Global_member_priv_ref(TYPE, NAME, DOCSTRING) \
241 _Global_member_priv (TYPE, NAME, DOCSTRING)
242
243 #define _Global_member_priv_eref(TYPE, NAME, DOCSTRING) \
244 _Global_member_priv (TYPE, NAME, DOCSTRING)
245
246 #define _Global_member_priv_ptr(TYPE, NAME, DOCSTRING) \
247 _Global_member_priv (TYPE *, NAME, DOCSTRING)
248
249 #define _Global_member_priv_obj(TYPE, NAME, DOCSTRING) \
250 private: \
251 TYPE *_m_##NAME; \
252 protected: \
253 TYPE *&m_##NAME(); \
254 TYPE *const &m_##NAME() const; \
255 public:
256
257
258 #define _Global_member_ri_ptr(TYPE, NAME, DOCSTRING) \
259 _Global_member_priv_ptr (TYPE, NAME, DOCSTRING) \
260 TYPE *NAME(); \
261 TYPE const *NAME() const;
262
263 #define _Global_member_ri_obj(TYPE, NAME, DOCSTRING) \
264 _Global_member_priv_obj (TYPE, NAME, DOCSTRING) \
265 TYPE *NAME(); \
266 TYPE const *NAME() const;
267
268
269 #define _Global_member_ri_ref(TYPE, NAME, DOCSTRING) \
270 _Global_member_priv_ref (TYPE, NAME, DOCSTRING) \
271 TYPE *NAME(); \
272 TYPE const *NAME() const;
273
274 #define _Global_member_ri_eref(TYPE, NAME, DOCSTRING) \
275 _Global_member_priv_eref (TYPE, NAME, DOCSTRING) \
276 TYPE &NAME(); \
277 TYPE const &NAME() const;
278
279
280 #define _Global_member_ro(TYPE, NAME, DOCSTRING) \
281 _Global_member_priv (TYPE, NAME, DOCSTRING) \
282 TYPE NAME() const;
283
284
285
286
287
288 #define _Global_member_ro_ref(TYPE, NAME, DOCSTRING) \
289 _Global_member_priv_ref (TYPE, NAME, DOCSTRING) \
290 TYPE const *NAME() const;
291
292
293 #define _Global_member_ro_eref(TYPE, NAME, DOCSTRING) \
294 _Global_member_priv_eref (TYPE, NAME, DOCSTRING) \
295 TYPE const &NAME() const;
296
297
298 #define _Global_member_ro_ptr(TYPE, NAME, DOCSTRING) \
299 _Global_member_priv_ptr (TYPE, NAME, DOCSTRING) \
300 TYPE *NAME() const;
301
302 #define _Global_member_ro_obj(TYPE, NAME, DOCSTRING) \
303 _Global_member_priv_obj (TYPE, NAME, DOCSTRING) \
304 TYPE *NAME() const;
305
306
307 #define _Global_member_rw(TYPE, NAME, DOCSTRING) \
308 _Global_member_priv (TYPE, NAME, DOCSTRING) \
309 TYPE NAME() const; \
310 void set_##NAME (TYPE a);
311
312 #define _Global_member_rw_ref(TYPE, NAME, DOCSTRING) \
313 _Global_member_priv_ref (TYPE, NAME, DOCSTRING) \
314 TYPE *NAME(); \
315 TYPE const *NAME() const; \
316 void set_##NAME (TYPE const *a);
317
318 #define _Global_member_rw_eref(TYPE, NAME, DOCSTRING) \
319 _Global_member_priv_eref (TYPE, NAME, DOCSTRING) \
320 TYPE &NAME(); \
321 TYPE const &NAME() const; \
322 void set_##NAME (TYPE const &a);
323
324 #define _Global_member_rw_ptr(TYPE, NAME, DOCSTRING) \
325 _Global_member_priv_ptr (TYPE, NAME, DOCSTRING) \
326 TYPE *NAME() const; \
327 void set_##NAME (TYPE *a); \
328 void reset_##NAME ();
329
330 #define _Global_member_rw_obj(TYPE, NAME, DOCSTRING) \
331 _Global_member_priv_obj (TYPE, NAME, DOCSTRING) \
332 TYPE *NAME() const; \
333 void set_##NAME (TYPE *a); \
334 void reset_##NAME ();
335
336
337 #define _Global_member_rp(TYPE, NAME, DOCSTRING) \
338 _Global_member_priv (TYPE, NAME, DOCSTRING) \
339 TYPE NAME() const; \
340 protected: \
341 void set_##NAME (TYPE a); \
342 public:
343
344 #define _Global_member_rp_ref(TYPE, NAME, DOCSTRING) \
345 _Global_member_priv_ref (TYPE, NAME, DOCSTRING) \
346 TYPE const *NAME() const; \
347 protected: \
348 TYPE *NAME(); \
349 void set_##NAME (TYPE const *a); \
350 public:
351
352 #define _Global_member_rp_eref(TYPE, NAME, DOCSTRING) \
353 _Global_member_priv_eref (TYPE, NAME, DOCSTRING) \
354 TYPE const &NAME() const; \
355 protected: \
356 TYPE &NAME(); \
357 void set_##NAME (TYPE const &a); \
358 public:
359
360 #define _Global_member_rp_ptr(TYPE, NAME, DOCSTRING) \
361 _Global_member_priv_ptr (TYPE, NAME, DOCSTRING) \
362 TYPE *NAME() const; \
363 protected: \
364 void set_##NAME (TYPE *a); \
365 void reset_##NAME (); \
366 public:
367
368 #define _Global_member_rp_obj(TYPE, NAME, DOCSTRING) \
369 _Global_member_priv_obj (TYPE, NAME, DOCSTRING) \
370 TYPE *NAME() const; \
371 protected: \
372 void set_##NAME (TYPE *a); \
373 void reset_##NAME (); \
374 public:
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389 #define Global_child_priv(TYPE, NAME, DOCSTRING) _Global_member_priv (TYPE, NAME, DOCSTRING)
390 #define Global_child_priv_ref(TYPE, NAME, DOCSTRING) _Global_member_priv_ref (TYPE, NAME, DOCSTRING)
391 #define Global_child_priv_eref(TYPE, NAME, DOCSTRING) _Global_member_priv_eref (TYPE, NAME, DOCSTRING)
392 #define Global_child_priv_ptr(TYPE, NAME, DOCSTRING) _Global_member_priv_ptr (TYPE, NAME, DOCSTRING)
393 #define Global_child_priv_obj(TYPE, NAME, DOCSTRING) _Global_member_priv_obj (TYPE, NAME, DOCSTRING)
394 #define Global_child_ri_obj(TYPE, NAME, DOCSTRING) _Global_member_ri_obj (TYPE, NAME, DOCSTRING)
395 #define Global_child_ri_ptr(TYPE, NAME, DOCSTRING) _Global_member_ri_ptr (TYPE, NAME, DOCSTRING)
396 #define Global_child_ri_ref(TYPE, NAME, DOCSTRING) _Global_member_ri_ref (TYPE, NAME, DOCSTRING)
397 #define Global_child_ri_eref(TYPE, NAME, DOCSTRING) _Global_member_ri_eref (TYPE, NAME, DOCSTRING)
398 #define Global_child_ro(TYPE, NAME, DOCSTRING) _Global_member_ro (TYPE, NAME, DOCSTRING)
399 #define Global_child_ro_obj(TYPE, NAME, DOCSTRING) _Global_member_ro_obj (TYPE, NAME, DOCSTRING)
400 #define Global_child_ro_ptr(TYPE, NAME, DOCSTRING) _Global_member_ro_ptr (TYPE, NAME, DOCSTRING)
401 #define Global_child_ro_ref(TYPE, NAME, DOCSTRING) _Global_member_ro_ref (TYPE, NAME, DOCSTRING)
402 #define Global_child_ro_eref(TYPE, NAME, DOCSTRING) _Global_member_ro_eref (TYPE, NAME, DOCSTRING)
403 #define Global_child_rw(TYPE, NAME, DOCSTRING) _Global_member_rw (TYPE, NAME, DOCSTRING)
404 #define Global_child_rw_obj(TYPE, NAME, DOCSTRING) _Global_member_rw_obj (TYPE, NAME, DOCSTRING)
405 #define Global_child_rw_ptr(TYPE, NAME, DOCSTRING) _Global_member_rw_ptr (TYPE, NAME, DOCSTRING)
406 #define Global_child_rw_ref(TYPE, NAME, DOCSTRING) _Global_member_rw_ref (TYPE, NAME, DOCSTRING)
407 #define Global_child_rw_eref(TYPE, NAME, DOCSTRING) _Global_member_rw_eref (TYPE, NAME, DOCSTRING)
408 #define Global_child_rp(TYPE, NAME, DOCSTRING) _Global_member_rp (TYPE, NAME, DOCSTRING)
409 #define Global_child_rp_obj(TYPE, NAME, DOCSTRING) _Global_member_rp_obj (TYPE, NAME, DOCSTRING)
410 #define Global_child_rp_ptr(TYPE, NAME, DOCSTRING) _Global_member_rp_ptr (TYPE, NAME, DOCSTRING)
411 #define Global_child_rp_ref(TYPE, NAME, DOCSTRING) _Global_member_rp_ref (TYPE, NAME, DOCSTRING)
412 #define Global_child_rp_eref(TYPE, NAME, DOCSTRING) _Global_member_rp_eref (TYPE, NAME, DOCSTRING)
413
414 #define Global_xref_priv_obj(TYPE, NAME, DOCSTRING) _Global_member_priv_obj (TYPE, NAME, DOCSTRING)
415 #define Global_xref_priv_ptr(TYPE, NAME, DOCSTRING) _Global_member_priv_ptr (TYPE, NAME, DOCSTRING)
416 #define Global_xref_ri_obj(TYPE, NAME, DOCSTRING) _Global_member_ri_obj (TYPE, NAME, DOCSTRING)
417 #define Global_xref_ri_ptr(TYPE, NAME, DOCSTRING) _Global_member_ri_ptr (TYPE, NAME, DOCSTRING)
418 #define Global_xref_ro_obj(TYPE, NAME, DOCSTRING) _Global_member_ro_obj (TYPE, NAME, DOCSTRING)
419 #define Global_xref_ro_ptr(TYPE, NAME, DOCSTRING) _Global_member_ro_ptr (TYPE, NAME, DOCSTRING)
420 #define Global_xref_rw_obj(TYPE, NAME, DOCSTRING) _Global_member_rw_obj (TYPE, NAME, DOCSTRING)
421 #define Global_xref_rw_ptr(TYPE, NAME, DOCSTRING) _Global_member_rw_ptr (TYPE, NAME, DOCSTRING)
422 #define Global_xref_rp_obj(TYPE, NAME, DOCSTRING) _Global_member_rp_obj (TYPE, NAME, DOCSTRING)
423 #define Global_xref_rp_ptr(TYPE, NAME, DOCSTRING) _Global_member_rp_ptr (TYPE, NAME, DOCSTRING)
424
425 #define Global_foreign_class(TYPE_CXX)--WITH-GLOBAL-- \
426 --WITH-GLOBAL-- typedef ERWIN_CONCAT_TOKEN (GlobalUCFirst_, TYPE_CXX) TYPE_CXX;
427
428 #define Global_foreign_type(TYPE_C)--WITH-GLOBAL-- \
429 --WITH-GLOBAL-- typedef ERWIN_CONCAT_TOKEN (Global_, TYPE_C) TYPE_C;
430
431 #define Global_local_class(TYPE_CXX)--WITH-GLOBAL-- \
432 --WITH-GLOBAL-- typedef ERWIN_CONCAT_TOKEN (GlobalUCFirst_, TYPE_CXX) TYPE_CXX;
433
434 #define Global_local_type(TYPE_C, TYPE_CXX)--WITH-GLOBAL-- \
435 --WITH-GLOBAL-- typedef ERWIN_CONCAT_TOKEN (Global_, TYPE_C) TYPE_C; \
436 --WITH-GLOBAL-- typedef ERWIN_CONCAT_TOKEN (Global_, TYPE_C) TYPE_CXX;
437
438 #define Global_local_enum(TYPE_C, TYPE_CXX)--WITH-GLOBAL-- \
439 --WITH-GLOBAL-- typedef ERWIN_CONCAT_TOKEN (Global_, TYPE_C) TYPE_C; \
440 --WITH-GLOBAL-- typedef ERWIN_CONCAT_TOKEN (Global_, TYPE_C) TYPE_CXX;
441
442 #define Global_local_union(TYPE_C, TYPE_CXX)--WITH-GLOBAL-- \
443 --WITH-GLOBAL-- typedef ERWIN_CONCAT_TOKEN (Global_, TYPE_C) TYPE_C; \
444 --WITH-GLOBAL-- typedef ERWIN_CONCAT_TOKEN (Global_, TYPE_C) TYPE_CXX;
445
446
447 #if ERWIN_BOOL_VALUE(Global_ERWIN_CLASS_REFCOUNT)
448 # define Global_stdclass_refcount \
449 THIS const *_ref() const \
450 { return ((THIS const *)((Object const *)(this))->_ref()); } \
451 THIS *_ref() \
452 { return ((THIS *)((Object *)(this))->_ref()); } \
453 THIS const *_unref() const \
454 { return ((THIS const *)((Object const *)(this))->_unref()); } \
455 THIS *_unref() \
456 { return ((THIS *)((Object *)(this))->_unref()); } \
457 THIS const *_ref_unref() const \
458 { return ((THIS const *)((Object const *)(this))->_ref_unref()); } \
459 THIS *_ref_unref() \
460 { return ((THIS *)((Object *)(this))->_ref_unref()); } \
461 THIS const *_unref_no_delete() const \
462 { return ((THIS const *)((Object const *)(this))->_unref_no_delete()); } \
463 THIS *_unref_no_delete() \
464 { return ((THIS *)((Object *)(this))->_unref_no_delete()); }
465 #elif ERWIN_BOOL_VALUE(Global_ERWIN_CLASS_REFCOUNT_FAKE)
466 # define Global_stdclass_refcount \
467 THIS const *_ref() const { return this; } \
468 THIS *_ref() { return this; } \
469 THIS const *_unref() const { return this; } \
470 THIS *_unref() { return this; } \
471 THIS const *_ref_unref() const { return this; } \
472 THIS *_ref_unref() { return this; } \
473 THIS const *_unref_no_delete() const { return this; } \
474 THIS *_unref_no_delete() { return this; }
475 #else
476 # define Global_stdclass_refcount
477 #endif
478
479 #define Global_stdclass_no_ref \
480 public: \
481 typedef THIS This; \
482 typedef SUPER Super; \
483 protected: \
484 virtual THIS *ERWIN_CONCAT_TOKEN(v_as_, THIS) (); \
485 public:
486
487 #define Global_stdclass \
488 Global_stdclass_no_ref \
489 public: \
490 Global_stdclass_refcount
491
492 #ifndef Global_SET_ID
493 #define Global_SET_ID(X) do{;}while(0)
494 #endif
495
496 #if ERWIN_BOOL_VALUE(Global_ERWIN_CLASS_ID)
497 # define Global_concrete_id \
498 private: \
499 void set_id() { Global_SET_ID(ERWIN_CONCAT_TOKEN(Global_id_, THIS)); } \
500 protected: \
501 virtual class_id_t v_klass_id() const { return ERWIN_CONCAT_TOKEN(Global_id_,THIS);}
502 #else
503 # define Global_concrete_id
504 #endif
505
506 #define Global_concrete \
507 Global_stdclass \
508 private: \
509 virtual void _concrete () const { } \
510 protected: \
511 virtual char const *v_klass_name() const { return ERWIN_STR(THIS); } \
512 Global_concrete_id \
513 public:
514
515
516 #if ERWIN_BOOL_VALUE(Global_ERWIN_CLASS_ID)
517 # define Global_abstract_id \
518 protected: \
519 virtual class_id_t v_klass_id() const = 0;
520 #else
521 # define Global_abstract_id
522 #endif
523
524
525 #define Global_abstract \
526 Global_stdclass \
527 private: \
528 virtual void _concrete () const = 0; \
529 protected: \
530 virtual char const *v_klass_name() const = 0; \
531 Global_abstract_id \
532 public:
533
534
535 #define Global_abstract_no_ref \
536 Global_stdclass_no_ref \
537 private: \
538 virtual void _concrete () const = 0; \
539 protected: \
540 virtual char const *v_klass_name() const = 0; \
541 Global_abstract_id \
542 public:
543
544
545 #if ERWIN_BOOL_VALUE(Global_ERWIN_CLASS_ID)
546 # define Global_general_object_id \
547 protected: \
548 virtual class_id_t klass_id() const \
549 { return this == NULL ? Global_id_NULL : v_klass_id(); }
550 #else
551 # define Global_general_object_id
552 #endif
553
554
555 #define Global_general_object \
556 typedef Object This; \
557 announce_class(Object) \
558 private: \
559 virtual void _concrete () const = 0; \
560 protected: \
561 virtual char const *v_klass_name() const = 0; \
562 Global_abstract_id \
563 public: \
564 char const *klass_name() const { return this == NULL ? NULL : v_klass_name(); } \
565 Global_general_object_id
566
567
568 #define Global_make_cast(TYPE) \
569 public: \
570 TYPE *cast_##TYPE (); \
571 TYPE const *cast_##TYPE () const;
572
573 #define Global_announce_class(TYPE) \
574 protected: \
575 virtual TYPE *v_as_##TYPE(); \
576 Global_make_cast(TYPE) \
577 public: \
578 TYPE *as_##TYPE (); \
579 TYPE const *as_##TYPE () const;
580
581
582
583
584
585 #define Global_hidden private
586 #define Global_trivial
587 #define Global_redirect
588 #define Global_inherit
589
590
591 #undef THIS
592 #undef SUPER
593
594
595 #define Global_THIS ERWIN_CONCAT_TOKEN(GlobalUCFirst_, THIS)
596 #define Global_SUPER ERWIN_CONCAT_TOKEN(GlobalUCFirst_, SUPER)
597
598 #if !ERWIN_BOOL_VALUE(Global_ERWIN_CLASS_USE_CGEN)
599
600 #ifdef Global_ERWIN_COMPILING
601 # include "--INCPREF2B--erwin/classundef.h"
602 #else
603 # include <--INCPREF2B--erwin/classundef.h>
604 #endif
605 #endif
606
607 #endif
608
609
610
611
612
613
614 --WITH-GLOBAL--#define child_priv Global_child_priv
615 --WITH-GLOBAL--#define child_priv_ref Global_child_priv_ref
616 --WITH-GLOBAL--#define child_priv_eref Global_child_priv_eref
617 --WITH-GLOBAL--#define child_priv_ptr Global_child_priv_ptr
618 --WITH-GLOBAL--#define child_priv_obj Global_child_priv_obj
619 --WITH-GLOBAL--#define child_ri_obj Global_child_ri_obj
620 --WITH-GLOBAL--#define child_ri_ptr Global_child_ri_ptr
621 --WITH-GLOBAL--#define child_ri_ref Global_child_ri_ref
622 --WITH-GLOBAL--#define child_ri_eref Global_child_ri_eref
623 --WITH-GLOBAL--#define child_ro Global_child_ro
624 --WITH-GLOBAL--#define child_ro_obj Global_child_ro_obj
625 --WITH-GLOBAL--#define child_ro_ptr Global_child_ro_ptr
626 --WITH-GLOBAL--#define child_ro_ref Global_child_ro_ref
627 --WITH-GLOBAL--#define child_ro_eref Global_child_ro_eref
628 --WITH-GLOBAL--#define child_rw Global_child_rw
629 --WITH-GLOBAL--#define child_rw_obj Global_child_rw_obj
630 --WITH-GLOBAL--#define child_rw_ptr Global_child_rw_ptr
631 --WITH-GLOBAL--#define child_rw_ref Global_child_rw_ref
632 --WITH-GLOBAL--#define child_rw_eref Global_child_rw_eref
633 --WITH-GLOBAL--#define child_rp Global_child_rp
634 --WITH-GLOBAL--#define child_rp_obj Global_child_rp_obj
635 --WITH-GLOBAL--#define child_rp_ptr Global_child_rp_ptr
636 --WITH-GLOBAL--#define child_rp_ref Global_child_rp_ref
637 --WITH-GLOBAL--#define child_rp_eref Global_child_rp_eref
638 --WITH-GLOBAL--#define xref_priv_obj Global_xref_priv_obj
639 --WITH-GLOBAL--#define xref_priv_ptr Global_xref_priv_ptr
640 --WITH-GLOBAL--#define xref_ri_obj Global_xref_ri_obj
641 --WITH-GLOBAL--#define xref_ri_ptr Global_xref_ri_ptr
642 --WITH-GLOBAL--#define xref_ro_obj Global_xref_ro_obj
643 --WITH-GLOBAL--#define xref_ro_ptr Global_xref_ro_ptr
644 --WITH-GLOBAL--#define xref_rw_obj Global_xref_rw_obj
645 --WITH-GLOBAL--#define xref_rw_ptr Global_xref_rw_ptr
646 --WITH-GLOBAL--#define xref_rp_obj Global_xref_rp_obj
647 --WITH-GLOBAL--#define xref_rp_ptr Global_xref_rp_ptr
648
649 --WITH-GLOBAL--#define stdclass Global_stdclass
650 --WITH-GLOBAL--#define stdclass_no_ref Global_stdclass_no_ref
651 --WITH-GLOBAL--#define concrete Global_concrete
652 --WITH-GLOBAL--#define abstract Global_abstract
653 --WITH-GLOBAL--#define abstract_no_ref Global_abstract_no_ref
654 --WITH-GLOBAL--#define general_object Global_general_object
655
656 --WITH-GLOBAL--#define announce_class Global_announce_class
657
658 --WITH-GLOBAL--#define hidden Global_hidden
659 --WITH-GLOBAL--#define trivial Global_trivial
660 --WITH-GLOBAL--#define redirect Global_redirect
661 --WITH-GLOBAL--#define inherit Global_inherit
662
663 --WITH-GLOBAL--#define foreign_class Global_foreign_class
664 --WITH-GLOBAL--#define foreign_type Global_foreign_type
665 --WITH-GLOBAL--#define local_class Global_local_class
666 --WITH-GLOBAL--#define local_type Global_local_type
667 --WITH-GLOBAL--#define local_enum Global_local_enum
668 --WITH-GLOBAL--#define local_union Global_local_union
669
670