Debian Codegraph @

intl/icu_capi/bindings/cpp/diplomat_runtime.h

raw
1 #ifndef DIPLOMAT_RUNTIME_C_H
2 #define DIPLOMAT_RUNTIME_C_H
3
4 #include <stdint.h>
5 #include <stddef.h>
6 #include <stdbool.h>
7 #include <sys/types.h>
8
9 // uchar.h doesn't always exist, but char32_t is always available
10 // in C++ anyway
11 #ifndef __cplusplus
12 #ifdef __APPLE__
13 #include <stdint.h>
14 typedef uint16_t char16_t;
15 typedef uint32_t char32_t;
16 #else
17 #include <uchar.h>
18 #endif
19 #endif
20
21
22 #ifdef __cplusplus
23 namespace capi {
24 extern "C" {
25 #endif
26
27 typedef struct DiplomatWriteable {
28 void* context;
29 char* buf;
30 size_t len;
31 size_t cap;
32 void (*flush)(struct DiplomatWriteable*);
33 bool (*grow)(struct DiplomatWriteable*, size_t);
34 } DiplomatWriteable;
35
36 DiplomatWriteable diplomat_simple_writeable(char* buf, size_t buf_size);
37
38 #define MAKE_SLICES(name, c_ty) \
39 typedef struct Diplomat##name##View { \
40 const c_ty* data; \
41 size_t len; \
42 } Diplomat##name##View; \
43 typedef struct Diplomat##name##Array { \
44 const c_ty* data; \
45 size_t len; \
46 } Diplomat##name##Array;
47
48 MAKE_SLICES(I8, int8_t)
49 MAKE_SLICES(U8, uint8_t)
50 MAKE_SLICES(I16, int16_t)
51 MAKE_SLICES(U16, uint16_t)
52 MAKE_SLICES(I32, int32_t)
53 MAKE_SLICES(U32, uint32_t)
54 MAKE_SLICES(I64, int64_t)
55 MAKE_SLICES(U64, uint64_t)
56 MAKE_SLICES(Isize, intptr_t)
57 MAKE_SLICES(Usize, size_t)
58 MAKE_SLICES(F32, float)
59 MAKE_SLICES(F64, double)
60 MAKE_SLICES(Bool, bool)
61 MAKE_SLICES(Char, char32_t)
62 MAKE_SLICES(String, char)
63 MAKE_SLICES(U16String, char16_t)
64
65
66 #ifdef __cplusplus
67 } // extern "C"
68 } // namespace capi
69 #endif
70
71 #endif