/runtime/typeinfo/ti_char.d

http://github.com/wilkie/djehuty · D · 45 lines · 28 code · 11 blank · 6 comment · 1 complexity · 16c08691593c576a272da48b9ba5b6b2 MD5 · raw file

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