Cthulhu  0.2.10
Cthulhu compiler collection
typeinfo.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-only
2 #pragma once
3 
4 #include <ctu_std_api.h>
5 
6 #include "core/compiler.h"
7 #include "core/analyze.h"
8 #include "core/types.h"
9 
10 #include <stdbool.h>
11 #include <stddef.h>
12 #include <stdint.h>
13 
15 
20 
26 typedef ctu_hash_t (*hash_fn_t)(const void *key);
27 
35 typedef bool (*equals_fn_t)(const void *lhs, const void *rhs);
36 
38 typedef struct hash_info_t
39 {
41  STA_FIELD_RANGE(0, SIZE_MAX) size_t size;
42 
45 
48 } hash_info_t;
49 
51 CT_STD_API extern const hash_info_t kTypeInfoString;
52 
55 CT_STD_API extern const hash_info_t kTypeInfoPtr;
56 
58 CT_STD_API extern const hash_info_t kTypeInfoText;
59 
61 
CT_NODISCARD size_t size
Definition: scan.h:128
#define CT_BEGIN_API
Definition: compiler.h:129
#define CT_END_API
Definition: compiler.h:130
size_t ctu_hash_t
Definition: types.h:8
CT_STD_API const hash_info_t kTypeInfoString
type information for a c style string
Definition: typeinfo.c:35
bool(* equals_fn_t)(const void *lhs, const void *rhs)
compare two objects pointed to by lhs and rhs
Definition: typeinfo.h:35
CT_STD_API const hash_info_t kTypeInfoPtr
type information for a generic pointer this operates on the pointer itself and not the data it points...
Definition: typeinfo.c:41
ctu_hash_t(* hash_fn_t)(const void *key)
hash an object pointed to by key
Definition: typeinfo.h:26
CT_STD_API const hash_info_t kTypeInfoText
type information for a text_view_t
Definition: typeinfo.c:47
information for using a type in a hashset or hashmap
Definition: typeinfo.h:39
hash_fn_t hash
the hash function for the type
Definition: typeinfo.h:44
equals_fn_t equals
the equality function for the type
Definition: typeinfo.h:47
STA_FIELD_RANGE(0, SIZE_MAX) size_t size
the size of the type