]>
Commit | Line | Data |
---|---|---|
2b0a63a3 MM |
1 | // Build don't link: |
2 | // Origin: Steven Parkes <parkes@sierravista.com> | |
3 | ||
a1ac6acc | 4 | typedef __SIZE_TYPE__ size_t; |
2b0a63a3 MM |
5 | |
6 | class UUId {}; | |
7 | ||
8 | template <class T> class MetaClass; | |
9 | ||
10 | class TypeInfo; | |
11 | ||
12 | struct MetaClassGeneric | |
13 | { | |
14 | MetaClassGeneric( TypeInfo& ); | |
15 | }; | |
16 | ||
17 | struct TypeInfo | |
18 | { | |
19 | void (*constructor)( void* ); | |
20 | void initialize( void* ); | |
21 | }; | |
22 | ||
23 | template <class T> | |
24 | class TypeIDInit { | |
25 | public: | |
26 | TypeIDInit(); | |
27 | static void initialize(); | |
28 | static TypeInfo info; | |
29 | static int storage[]; | |
30 | static void metaclassConstructor( void* ); | |
31 | }; | |
32 | ||
33 | template <class T> | |
34 | TypeInfo TypeIDInit<T>::info = | |
35 | { | |
36 | TypeIDInit<T>::metaclassConstructor | |
37 | }; | |
38 | ||
39 | template <class T> | |
40 | inline | |
41 | TypeIDInit<T>::TypeIDInit() | |
42 | { | |
43 | info.initialize(storage); | |
44 | } | |
45 | ||
46 | template <class T> | |
47 | class NameInfo : public MetaClassGeneric { | |
48 | public: | |
49 | NameInfo() | |
50 | : MetaClassGeneric( TypeIDInit<T>::info ) {} | |
51 | }; | |
52 | ||
53 | class MetaClass<UUId> | |
54 | : public NameInfo<UUId> | |
55 | { | |
56 | }; | |
57 | ||
58 | extern "C++" | |
59 | inline void *operator new(size_t, void *place) throw() { return place; } | |
60 | ||
61 | template <class T> | |
62 | void | |
63 | TypeIDInit<T>::metaclassConstructor( void* place ) | |
64 | { | |
65 | new ( place ) MetaClass<T>; | |
66 | } | |
67 | ||
68 | template class TypeIDInit<UUId> ; | |
69 |