/src/rt/typeinfo/ti_delegate.d

http://github.com/AlexeyProkhin/druntime · D · 57 lines · 33 code · 11 blank · 13 comment · 1 complexity · b550b1b0324fa0f1ab68ffc0ccdfaf9b 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_delegate;
  14. private import rt.util.hash;
  15. // delegate
  16. alias void delegate(int) dg;
  17. class TypeInfo_D : TypeInfo
  18. {
  19. @trusted:
  20. const:
  21. pure:
  22. nothrow:
  23. override size_t getHash(in void* p)
  24. {
  25. return hashOf(p, dg.sizeof);
  26. }
  27. override bool equals(in void* p1, in void* p2)
  28. {
  29. return *cast(dg *)p1 == *cast(dg *)p2;
  30. }
  31. override @property size_t tsize() nothrow pure
  32. {
  33. return dg.sizeof;
  34. }
  35. override void swap(void *p1, void *p2)
  36. {
  37. dg t;
  38. t = *cast(dg *)p1;
  39. *cast(dg *)p1 = *cast(dg *)p2;
  40. *cast(dg *)p2 = t;
  41. }
  42. override @property uint flags() nothrow pure
  43. {
  44. return 1;
  45. }
  46. }