123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- // Humming Owl's Multipurpose Library
- #ifndef HOML_H
- #define HOML_H
- // HOML header includes
- #include "basic_types.h"
- #include "mem_space.h"
- #include "endian.h"
- #include "other_types/byte_arr.h"
- // useful definitions for a kind of "typeof" function (might be a dumb addition)
- // using the enums chained between headers (first one is in basic_types.h)
- // typeof
- owl_char * OWL_TYPE_NAMES[] =
- {
- "OWL_BYTE",
- "OWL_CHAR",
- "OWL_UMAX",
- "OWL_SMAX",
- "OWL_FMAX",
- "OWL_BOOL",
- "OWL_MEM_SPACE",
- "OWL_MEM_SPACE_ERR",
- "OWL_ENDIAN",
- "OWL_BYTESHIFT_DIR",
- "OWL_BYTARR",
- };
- // sizeof
- owl_umax OWL_TYPE_SIZES[] =
- {
- sizeof(owl_byte),
- sizeof(owl_char),
- sizeof(owl_umax),
- sizeof(owl_smax),
- sizeof(owl_fmax),
- sizeof(owl_bool),
- sizeof(owl_endian),
- sizeof(owl_mem_space),
- sizeof(owl_mem_space_err),
- sizeof(owl_byteshift_dir),
- sizeof(owl_bytarr),
- };
- // function to return the type string of a type integer
- owl_char * owl_type_name(owl_umax type_id)
- {
- // check params
- if (type_id > sizeof(OWL_TYPE_NAMES) - 1)
- return NULL;
- return OWL_TYPE_NAMES[type_id];
- }
- // function to return the type size of a type integer
- owl_umax owl_type_size(owl_umax type_id)
- {
- // check params
- if (type_id > sizeof(OWL_TYPE_NAMES) - 1)
- return 0;
- return OWL_TYPE_SIZES[type_id];
- }
- #endif // HOML_H
|