homl.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Humming Owl's Multipurpose Library
  2. #ifndef HOML_H
  3. #define HOML_H
  4. // HOML header includes
  5. #include "basic_types.h"
  6. #include "mem_space.h"
  7. #include "endian.h"
  8. #include "other_types/byte_arr.h"
  9. // useful definitions for a kind of "typeof" function (might be a dumb addition)
  10. // using the enums chained between headers (first one is in basic_types.h)
  11. // typeof
  12. owl_char * OWL_TYPE_NAMES[] =
  13. {
  14. "OWL_BYTE",
  15. "OWL_CHAR",
  16. "OWL_UMAX",
  17. "OWL_SMAX",
  18. "OWL_FMAX",
  19. "OWL_BOOL",
  20. "OWL_MEM_SPACE",
  21. "OWL_MEM_SPACE_ERR",
  22. "OWL_ENDIAN",
  23. "OWL_BYTESHIFT_DIR",
  24. "OWL_BYTARR",
  25. };
  26. // sizeof
  27. owl_umax OWL_TYPE_SIZES[] =
  28. {
  29. sizeof(owl_byte),
  30. sizeof(owl_char),
  31. sizeof(owl_umax),
  32. sizeof(owl_smax),
  33. sizeof(owl_fmax),
  34. sizeof(owl_bool),
  35. sizeof(owl_endian),
  36. sizeof(owl_mem_space),
  37. sizeof(owl_mem_space_err),
  38. sizeof(owl_byteshift_dir),
  39. sizeof(owl_bytarr),
  40. };
  41. // function to return the type string of a type integer
  42. owl_char * owl_type_name(owl_umax type_id)
  43. {
  44. // check params
  45. if (type_id > sizeof(OWL_TYPE_NAMES) - 1)
  46. return NULL;
  47. return OWL_TYPE_NAMES[type_id];
  48. }
  49. // function to return the type size of a type integer
  50. owl_umax owl_type_size(owl_umax type_id)
  51. {
  52. // check params
  53. if (type_id > sizeof(OWL_TYPE_NAMES) - 1)
  54. return 0;
  55. return OWL_TYPE_SIZES[type_id];
  56. }
  57. #endif // HOML_H