Loading...
Searching...
No Matches
Go to the documentation of this file.
18#define __DeclareClass(type) \
20 void* operator new(size_t size) \
22 return RTTI.AllocInstanceMemory(); \
24 void* operator new[](size_t num) \
26 return RTTI.AllocInstanceMemoryArray(num); \
28 void operator delete(void* p) \
30 RTTI.FreeInstanceMemory(p); \
32 void operator delete(void* p, void*) \
35 void operator delete[](void* p) \
37 RTTI.FreeInstanceMemory(p); \
39 static Core::Rtti RTTI; \
40 static void* FactoryCreator(); \
41 static void* FactoryArrayCreator(SizeT num); \
42 static type* Create(); \
43 static type* CreateArray(SizeT num); \
44 static bool RegisterWithFactory(); \
45 virtual Core::Rtti* GetRtti() const; \
48#define __DeclareTemplateClass(type, temp) \
50 void* operator new(size_t size) \
52 return Memory::Alloc(Memory::ObjectHeap, size); \
54 void operator delete(void* p) \
56 Memory::Free(Memory::ObjectHeap, p); \
58 static type<temp>* Create(); \
59 static type<temp>* CreateArray(SizeT num); \
62#define __DeclareAbstractClass(class_name) \
64 static Core::Rtti RTTI; \
65 virtual Core::Rtti* GetRtti() const; \
73#define __RegisterClass(type) \
74 static const bool type##_registered = type::RegisterWithFactory(); \
84#define __ImplementClass(type, fourcc, baseType) \
85 Core::Rtti type::RTTI(#type, fourcc, type::FactoryCreator, type::FactoryArrayCreator, &baseType::RTTI, sizeof(type)); \
86 Core::Rtti* type::GetRtti() const { return &this->RTTI; } \
87 void* type::FactoryCreator() { return type::Create(); } \
88 void* type::FactoryArrayCreator(SizeT num) { return type::CreateArray(num); } \
89 type* type::Create() \
91 static_assert(std::is_base_of<Core::RefCounted, type>::value, "Class must inherit from Core::RefCounted"); \
92 RefCounted::criticalSection.Enter(); \
93 RefCounted::isInCreate = true; \
94 type* newObject = new type; \
95 RefCounted::isInCreate = false; \
96 RefCounted::criticalSection.Leave(); \
99 type* type::CreateArray(SizeT num) \
101 static_assert(std::is_base_of<Core::RefCounted, type>::value, "Class must inherit from Core::RefCounted"); \
102 RefCounted::criticalSection.Enter(); \
103 RefCounted::isInCreate = true; \
104 type* newObject = new type[num]; \
105 RefCounted::isInCreate = false; \
106 RefCounted::criticalSection.Leave(); \
109 bool type::RegisterWithFactory() \
111 Core::SysFunc::Setup(); \
112 if (!Core::Factory::Instance()->ClassExists(#type)) \
114 Core::Factory::Instance()->Register(&type::RTTI, #type, fourcc); \
122#define __ImplementClassTemplate(type, baseType) \
123 template <class TEMP> \
124 inline type<TEMP>* type<TEMP>::Create() \
126 RefCounted::criticalSection.Enter(); \
127 RefCounted::isInCreate = true; \
128 type<TEMP>* newObject = new type<TEMP>; \
129 RefCounted::isInCreate = false; \
130 RefCounted::criticalSection.Leave(); \
133 template <class TEMP> \
134 inline type<TEMP>* type<TEMP>::CreateArray(SizeT num) \
136 RefCounted::criticalSection.Enter(); \
137 RefCounted::isInCreate = true; \
138 type<TEMP>* newObject = new type<TEMP>[num]; \
139 RefCounted::isInCreate = false; \
140 RefCounted::criticalSection.Leave(); \
147#define __ImplementClassVariadicTemplate(type, baseType) \
148 template <class ... TEMP> \
149 inline type<TEMP...>* type<TEMP...>::Create() \
151 RefCounted::criticalSection.Enter(); \
152 RefCounted::isInCreate = true; \
153 type<TEMP...>* newObject = new type<TEMP...>; \
154 RefCounted::isInCreate = false; \
155 RefCounted::criticalSection.Leave(); \
158 template <class ... TEMP> \
159 inline type<TEMP...>* type<TEMP...>::CreateArray(SizeT num) \
161 RefCounted::criticalSection.Enter(); \
162 RefCounted::isInCreate = true; \
163 type<TEMP...>* newObject = new type<TEMP...>[num]; \
164 RefCounted::isInCreate = false; \
165 RefCounted::criticalSection.Leave(); \
172#define __ImplementClass(type, fourcc, baseType) \
173 Core::Rtti type::RTTI(#type, fourcc, type::FactoryCreator, type::FactoryArrayCreator, &baseType::RTTI, sizeof(type)); \
174 Core::Rtti* type::GetRtti() const { return &this->RTTI; } \
175 void* type::FactoryCreator() { return type::Create(); } \
176 void* type::FactoryArrayCreator(SizeT num) { return type::CreateArray(num); } \
177 type* type::Create() \
179 static_assert(std::is_base_of<Core::RefCounted, type>::value, "Class must inherit from Core::RefCounted"); \
182 type* type::CreateArray(SizeT num) \
184 static_assert(std::is_base_of<Core::RefCounted, type>::value, "Class must inherit from Core::RefCounted"); \
185 return new type[num]; \
187 bool type::RegisterWithFactory() \
189 Core::SysFunc::Setup(); \
190 if (!Core::Factory::Instance()->ClassExists(#type)) \
192 Core::Factory::Instance()->Register(&type::RTTI, #type, fourcc); \
200#define __ImplementClassTemplate(type, baseType) \
201 template <class TEMP> \
202 inline type<TEMP>* type<TEMP>::Create() \
204 type<TEMP>* newObject = new type<TEMP>; \
207 template <class TEMP> \
208 inline type<TEMP>* type<TEMP>::CreateArray(SizeT num) \
210 type<TEMP>* newObject = new type<TEMP>[num]; \
217#define __ImplementClassVariadicTemplate(type, baseType) \
218 template <class ... TEMP> \
219 inline type<TEMP...>* type<TEMP...>::Create() \
221 type<TEMP...>* newObject = new type<TEMP...>; \
224 template <class ... TEMP> \
225 inline type<TEMP...>* type<TEMP...>::CreateArray(SizeT num) \
227 type<TEMP...>* newObject = new type<TEMP...>[num]; \
235#define __ImplementWeakClass(type, fourcc, baseType) \
236 Core::Rtti type::RTTI(#type, fourcc, type::FactoryCreator, type::FactoryArrayCreator, &baseType::RTTI, sizeof(type)); \
237 Core::Rtti* type::GetRtti() const { return &this->RTTI; } \
238 void* type::FactoryCreator() { return type::Create(); } \
239 void* type::FactoryArrayCreator(SizeT num) { return type::CreateArray(num); } \
240 type* type::Create() \
242 type* newObject = new type; \
245 type* type::CreateArray(SizeT num) \
247 type* newObject = new type[num]; \
250 bool type::RegisterWithFactory() \
252 Core::SysFunc::Setup(); \
253 if (!Core::Factory::Instance()->ClassExists(#type)) \
255 Core::Factory::Instance()->Register(&type::RTTI, #type, fourcc); \
263#define __ImplementWeakRootClass(type, fourcc) \
264 Core::Rtti type::RTTI(#type, fourcc, type::FactoryCreator, type::FactoryArrayCreator, nullptr, sizeof(type)); \
265 Core::Rtti* type::GetRtti() const { return &this->RTTI; } \
266 void* type::FactoryCreator() { return type::Create(); } \
267 void* type::FactoryArrayCreator(SizeT num) { return type::CreateArray(num); } \
268 type* type::Create() \
270 type* newObject = new type; \
273 type* type::CreateArray(SizeT num) \
275 type* newObject = new type[num]; \
278 bool type::RegisterWithFactory() \
280 Core::SysFunc::Setup(); \
281 if (!Core::Factory::Instance()->ClassExists(#type)) \
283 Core::Factory::Instance()->Register(&type::RTTI, #type, fourcc); \
291#define __ImplementAbstractClass(type, fourcc, baseType) \
292 Core::Rtti type::RTTI(#type, fourcc, nullptr, nullptr, &baseType::RTTI, 0); \
293 Core::Rtti* type::GetRtti() const { return &this->RTTI; }
298#define __ImplementAbstractRootClass(type, fourcc) \
299 Core::Rtti type::RTTI(#type, fourcc, nullptr, nullptr, nullptr, 0); \
300 Core::Rtti* type::GetRtti() const { return &this->RTTI; }
308#define __ImplementRootClass(type, fourcc) \
309 Core::Rtti type::RTTI(#type, fourcc, type::FactoryCreator, type::FactoryArrayCreator, nullptr, sizeof(type)); \
310 Core::Rtti* type::GetRtti() const { return &this->RTTI; } \
311 void* type::FactoryCreator() { return type::Create(); } \
312 void* type::FactoryArrayCreator(SizeT num) { return type::CreateArray(num); } \
313 type* type::Create() \
315 static_assert(std::is_base_of<Core::RefCounted, type>::value, "Class must inherit from Core::RefCounted"); \
316 RefCounted::criticalSection.Enter(); \
317 RefCounted::isInCreate = true; \
318 type* newObject = new type; \
319 RefCounted::isInCreate = false; \
320 RefCounted::criticalSection.Leave(); \
323 type* type::CreateArray(SizeT num) \
325 static_assert(std::is_base_of<Core::RefCounted, type>::value, "Class must inherit from Core::RefCounted"); \
326 RefCounted::criticalSection.Enter(); \
327 RefCounted::isInCreate = true; \
328 type* newObject = new type[num]; \
329 RefCounted::isInCreate = false; \
330 RefCounted::criticalSection.Leave(); \
333 bool type::RegisterWithFactory() \
335 if (!Core::Factory::Instance()->ClassExists(#type)) \
337 Core::Factory::Instance()->Register(&type::RTTI, #type, fourcc); \
342#define __ImplementRootClass(type, fourcc) \
343 Core::Rtti type::RTTI(#type, fourcc, type::FactoryCreator, type::FactoryArrayCreator, nullptr, sizeof(type)); \
344 Core::Rtti* type::GetRtti() const { return &this->RTTI; } \
345 void* type::FactoryCreator() { return type::Create(); } \
346 void* type::FactoryArrayCreator(SizeT num) { return type::CreateArray(num); } \
347 type* type::Create() \
349 static_assert(std::is_base_of<Core::RefCounted, type>::value, "Class must inherit from Core::RefCounted"); \
352 type* type::CreateArray(SizeT num) \
354 static_assert(std::is_base_of<Core::RefCounted, type>::value, "Class must inherit from Core::RefCounted"); \
355 return new type[num]; \
357 bool type::RegisterWithFactory() \
359 if (!Core::Factory::Instance()->ClassExists(#type)) \
361 Core::Factory::Instance()->Register(&type::RTTI, #type, fourcc); \
367#define __SetupExternalAttributes() \
369 virtual void SetupExternalAttributes(); \
376#define __ImplementEnumBitOperators(type) \
377 inline type operator|(type a, type b) { return static_cast<type>(static_cast<unsigned>(a) | static_cast<unsigned>(b)); }\
378 inline type operator&(type a, type b) { return static_cast<type>(static_cast<unsigned>(a) & static_cast<unsigned>(b)); }\
379 inline type& operator|=(type& a, type b) { a = static_cast<type>(static_cast<unsigned>(a) | static_cast<unsigned>(b)); return a; }\
380 inline type& operator&=(type& a, type b) { a = static_cast<type>(static_cast<unsigned>(a) & static_cast<unsigned>(b)); return a; }\
381 inline type operator|(type a, unsigned b) { return static_cast<type>(static_cast<unsigned>(a) | b); }\
382 inline type operator&(type a, unsigned b) { return static_cast<type>(static_cast<unsigned>(a) & b); }\
383 inline type& operator|=(type& a, unsigned b) { a = static_cast<type>(static_cast<unsigned>(a) | b); return a; }\
384 inline type& operator&=(type& a, unsigned b) { a = static_cast<type>(static_cast<unsigned>(a) & b); return a; }\
385 inline type operator~(type a) { return static_cast<type>(~static_cast<unsigned>(a)); }\
386 inline type operator!(type a) { return static_cast<type>(!static_cast<unsigned>(a)); }\
387 inline unsigned operator|(unsigned a, type b) { return a | static_cast<unsigned>(b); }\
388 inline unsigned operator&(unsigned a, type b) { return a & static_cast<unsigned>(b); }\
389 inline unsigned& operator|=(unsigned& a, type b) { a = a | static_cast<unsigned>(b); return a; }\
390 inline unsigned& operator&=(unsigned& a, type b) { a = a & static_cast<unsigned>(b); return a; }
392#define __ImplementEnumComparisonOperators(type) \
393 inline bool operator>(type a, unsigned b) { return static_cast<unsigned>(a) > b; }\
394 inline bool operator>(unsigned a, type b) { return a > static_cast<unsigned>(b); }\
395 inline bool operator>(type a, int b) { return static_cast<int>(a) > b; }\
396 inline bool operator>(int a, type b) { return a > static_cast<int>(b); }\
397 inline bool operator<(type a, unsigned b) { return static_cast<unsigned>(a) < b; }\
398 inline bool operator<(unsigned a, type b) { return a < static_cast<unsigned>(b); }\
399 inline bool operator<(type a, int b) { return static_cast<unsigned>(a) < b; }\
400 inline bool operator<(int a, type b) { return a < static_cast<unsigned>(b); }\
401 inline bool operator>=(type a, unsigned b) { return static_cast<unsigned>(a) >= b; }\
402 inline bool operator>=(unsigned a, type b) { return a >= static_cast<unsigned>(b); }\
403 inline bool operator>=(type a, int b) { return static_cast<unsigned>(a) >= b; }\
404 inline bool operator>=(int a, type b) { return a >= static_cast<unsigned>(b); }\
405 inline bool operator<=(type a, unsigned b) { return static_cast<unsigned>(a) <= b; }\
406 inline bool operator<=(unsigned a, type b) { return a <= static_cast<unsigned>(b); }\
407 inline bool operator<=(type a, int b) { return static_cast<unsigned>(a) <= b; }\
408 inline bool operator<=(int a, type b) { return a <= static_cast<unsigned>(b); }\
409 inline bool operator==(type a, unsigned b) { return static_cast<unsigned>(a) == b; }\
410 inline bool operator==(unsigned a, type b) { return a == static_cast<unsigned>(b); }\
411 inline bool operator==(type a, int b) { return static_cast<unsigned>(a) == b; }\
412 inline bool operator==(int a, type b) { return a == static_cast<unsigned>(b); }\
413 inline bool operator!=(type a, unsigned b) { return static_cast<unsigned>(a) != b; }\
414 inline bool operator!=(unsigned a, type b) { return a != static_cast<unsigned>(b); }\
415 inline bool operator!=(type a, int b) { return static_cast<unsigned>(a) != b; }\
416 inline bool operator!=(int a, type b) { return a != static_cast<unsigned>(b); }
418#define __ImplementEnumMutableOperators(type) \
419 inline type operator++(type a) { return static_cast<type>(static_cast<unsigned>(a)++); }\
420 inline type operator--(type a) { return static_cast<type>(static_cast<unsigned>(a)--); }