Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
831 B

  1. #ifndef __PS3_RTTI__
  2. #define __PS3_RTTI__
  3. #include <stdio.h>
  4. namespace ps3_rtti
  5. {
  6. template<class Klass>
  7. class type_trait
  8. {
  9. private:
  10. static const size_t m_nameSize=16;
  11. public:
  12. static const int m_typeTag;
  13. static char m_name[m_nameSize];
  14. static int TypeInfo() {return int(&m_typeTag);}
  15. static const char* TypeName()
  16. {
  17. snprintf(m_name,m_nameSize,"%x",TypeInfo());
  18. return m_name;
  19. }
  20. };
  21. }
  22. #define TYPE_INFO int
  23. #define TYPEID(t) ps3_rtti::type_trait<t>::TypeInfo()
  24. #define TYPENAME(t) ps3_rtti::type_trait<t>::TypeName()
  25. #define TYPE_INFO_EQUAL(i1, i2) i1 == i2
  26. #define INSTANCTIATE_TYPE(t) \
  27. namespace ps3_rtti \
  28. { \
  29. template <> const int type_trait<t>::m_typeTag=0; \
  30. template <> char type_trait<t>::m_name[16] = ""; \
  31. }
  32. #define INVALID_TYPE_INFO int(0)
  33. #endif