nsgml: Resolve symbol collision when building with SunStudio 12.1
[oweals/cde.git] / cde / programs / nsgmls / rtti.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: rtti.h /main/1 1996/07/29 17:09:50 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
26
27 #ifndef rtti_INCLUDED
28 #define rtti_INCLUDED 1
29
30 #ifdef SP_HAVE_RTTI
31
32 #define DYNAMIC_CAST_PTR(T, p) dynamic_cast<T *>(p)
33 #define DYNAMIC_CAST_CONST_PTR(T, p) dynamic_cast<const T *>(p)
34
35 #define RTTI_CLASS
36
37 #define RTTI_DEF0(T)
38 #define RTTI_DEF1(T, B1)
39 #define RTTI_DEF2(T, B1, B2)
40 #define RTTI_DEF3(T, B1, B2, B3)
41
42 #else /* not SP_HAVE_RTTI */
43
44 #include "TypeId.h"
45
46 #define RTTI_CLASS \
47 public: \
48   virtual TypeId dynamicType() const; \
49   static inline TypeId staticType() { return TypeId(RTTI_bases_); } \
50 protected: \
51   static const void *RTTI_bases_[]; \
52 private:
53
54 #define RTTI_DEF0(T) \
55   const void *T::RTTI_bases_[] = { 0 }; \
56   TypeId T::dynamicType() const { return staticType(); }
57
58 #define RTTI_DEF1(T, B1) \
59   const void *T::RTTI_bases_[] = { B1::RTTI_bases_, 0 }; \
60   TypeId T::dynamicType() const { return staticType(); }
61
62 #define RTTI_DEF2(T, B1, B2) \
63   const void *T::RTTI_bases_[] = { B1::RTTI_bases_, B2::RTTI_bases_, 0 }; \
64   TypeId T::dynamicType() const { return staticType(); }
65
66 #define RTTI_DEF3(T, B1, B2, B3) \
67   const void *T::RTTI_bases_[] = { \
68     B1::RTTI_bases_, B2::RTTI_bases_, B3::RTTI_bases_, 0 }; \
69   TypeId T::dynamicType() const { return staticType(); }
70
71 #define DYNAMIC_CAST_PTR(T, p) \
72 ((p) && (p)->dynamicType().canCast(T::staticType(), (p)->staticType()) \
73  ? (T *)(p) \
74  : 0)
75 #define DYNAMIC_CAST_CONST_PTR(T, p) \
76 ((p) && (p)->dynamicType().canCast(T::staticType(), (p)->staticType()) \
77  ? (const T *)p \
78  : 0)
79
80 #endif /* not SP_HAVE_RTTI */
81
82 #endif /* not rtti_INCLUDED */