/runtime/typeinfo/ti_dchar.d

http://github.com/wilkie/djehuty · D · 47 lines · 28 code · 12 blank · 7 comment · 1 complexity · 1e3d10731c70a4bc0c2381ea1535969b MD5 · raw file

  1. /*
  2. * ti_dchar.d
  3. *
  4. * This module implements the TypeInfo for the dchar type.
  5. *
  6. */
  7. // dchar
  8. module runtime.d.typeinfo.ti_dchar;
  9. class TypeInfo_w : TypeInfo {
  10. char[] toString() {
  11. return "dchar";
  12. }
  13. hash_t getHash(void *p) {
  14. return *cast(dchar *)p;
  15. }
  16. int equals(void *p1, void *p2) {
  17. return *cast(dchar *)p1 == *cast(dchar *)p2;
  18. }
  19. int compare(void *p1, void *p2) {
  20. return *cast(dchar *)p1 - *cast(dchar *)p2;
  21. }
  22. size_t tsize() {
  23. return dchar.sizeof;
  24. }
  25. void swap(void *p1, void *p2) {
  26. dchar t;
  27. t = *cast(dchar *)p1;
  28. *cast(dchar *)p1 = *cast(dchar *)p2;
  29. *cast(dchar *)p2 = t;
  30. }
  31. void[] init() {
  32. static dchar c;
  33. return (cast(dchar *)&c)[0 .. 1];
  34. }
  35. }