Debian Codegraph @

dune/uggrid/parallel/ddd/basic/oopp.h

raw
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 // SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4 // SPDX-License-Identifier: LGPL-2.1-or-later
5 /****************************************************************************/
6 /* */
7 /* File: oopp.h */
8 /* */
9 /* Purpose: macros for implementing some rudimentary object-oriented */
10 /* techniques via the C preprocessor. */
11 /* */
12 /* Author: Klaus Birken */
13 /* Institut fuer Computeranwendungen III */
14 /* Universitaet Stuttgart */
15 /* Pfaffenwaldring 27 */
16 /* 70569 Stuttgart */
17 /* email: [email protected] */
18 /* phone: 0049-(0)711-685-7007 */
19 /* fax : 0049-(0)711-685-7000 */
20 /* */
21 /* History: 970720 kb begin */
22 /* */
23 /* Remarks: */
24 /* */
25 /****************************************************************************/
26
27
28
29 #ifndef __OOPP_H__
30 #define __OOPP_H__
31
32 /****************************************************************************/
33 /* */
34 /* basic text manipulation macros */
35 /* */
36 /****************************************************************************/
37
38 #define _CCAT(a,b) a ## b
39 #define CCAT(a,b) _CCAT(a,b)
40
41 #define CALL(a,b) CCAT(CCAT(a,_),b)
42
43
44
45 /****************************************************************************/
46 /* */
47 /* class declaration */
48 /* */
49 /****************************************************************************/
50
51 /* from now on, we assume a previous '#define ClassPrefix XXX' */
52 /* construction of class-name */
53 #ifdef ClassPrefix
54 #define CN(C) CCAT(ClassPrefix,C)
55 #else
56 #define CN(C) C
57 #endif
58
59
60 /* from now on, we suppose a '#define ClassName XXX' for a given class */
61
62 #define Class CN(ClassName) /* internal class-name */
63 #define ClassPtr Class*
64 #define ClassRef ClassPtr
65 /* #define VoidRef void * */
66 #define Class_Data_Begin struct Class {
67 #define Class_Data_End };
68
69 #define Method(M) CCAT(CCAT(ClassName,_),M)
70
71 /* support for easy 'This' */
72 #define This _oopp_this
73 /*
74 #define DefThis ClassRef
75 #define ParamThis ClassRef This
76 */
77 #define DefThis Class *
78 #define ParamThis Class * This
79
80
81 /****************************************************************************/
82 /* */
83 /* standard class methods */
84 /* */
85 /****************************************************************************/
86
87
88 /*** constructor (NewClass) ***/
89 /* macros for prototype */
90 #define Method_New_ ClassPtr CCAT(New_,ClassName)
91 #define Method_New(O) ClassPtr CCAT(CCAT(New_,ClassName),O) /* overload */
92
93 /* macros for implementation */
94 #define Construct(item,check) \
95 ClassPtr item=(ClassPtr) OO_Allocate (sizeof(Class)); \
96 { check; }
97
98 #define Destruct(item) OO_Free(item)
99
100
101 /****************************************************************************/
102 /* */
103 /* inheritance */
104 /* */
105 /****************************************************************************/
106
107 #define BaseClass(BC) typedef CN (BC) Class
108
109
110 /****************************************************************************/
111
112 #endif