/src/rt/typeinfo/ti_C.d

http://github.com/AlexeyProkhin/druntime · D · 70 lines · 44 code · 10 blank · 16 comment · 4 complexity · 54ca51fb923ef79558b4e1b8f5f111b1 MD5 · raw file

  1. /**
  2. * TypeInfo support code.
  3. *
  4. * Copyright: Copyright Digital Mars 2004 - 2009.
  5. * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
  6. * Authors: Walter Bright
  7. */
  8. /* Copyright Digital Mars 2004 - 2009.
  9. * Distributed under the Boost Software License, Version 1.0.
  10. * (See accompanying file LICENSE or copy at
  11. * http://www.boost.org/LICENSE_1_0.txt)
  12. */
  13. module rt.typeinfo.ti_C;
  14. // Object
  15. class TypeInfo_C : TypeInfo
  16. {
  17. @trusted:
  18. const:
  19. //pure:
  20. //nothrow:
  21. override size_t getHash(in void* p)
  22. {
  23. Object o = *cast(Object*)p;
  24. return o ? o.toHash() : 0;
  25. }
  26. override bool equals(in void* p1, in void* p2)
  27. {
  28. Object o1 = *cast(Object*)p1;
  29. Object o2 = *cast(Object*)p2;
  30. return o1 == o2;
  31. }
  32. override int compare(in void* p1, in void* p2)
  33. {
  34. Object o1 = *cast(Object*)p1;
  35. Object o2 = *cast(Object*)p2;
  36. int c = 0;
  37. // Regard null references as always being "less than"
  38. if (!(o1 is o2))
  39. {
  40. if (o1)
  41. {
  42. if (!o2)
  43. c = 1;
  44. else
  45. c = o1.opCmp(o2);
  46. }
  47. else
  48. c = -1;
  49. }
  50. return c;
  51. }
  52. override @property size_t tsize() nothrow pure
  53. {
  54. return Object.sizeof;
  55. }
  56. override @property uint flags() nothrow pure
  57. {
  58. return 1;
  59. }
  60. }