From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- intl/icu_capi/cpp/include/diplomat_runtime.h | 70 ++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 intl/icu_capi/cpp/include/diplomat_runtime.h (limited to 'intl/icu_capi/cpp/include/diplomat_runtime.h') diff --git a/intl/icu_capi/cpp/include/diplomat_runtime.h b/intl/icu_capi/cpp/include/diplomat_runtime.h new file mode 100644 index 0000000000..de0f9c76fe --- /dev/null +++ b/intl/icu_capi/cpp/include/diplomat_runtime.h @@ -0,0 +1,70 @@ +#ifndef DIPLOMAT_RUNTIME_C_H +#define DIPLOMAT_RUNTIME_C_H + +#include +#include +#include +#include + +// uchar.h doesn't always exist, but char32_t is always available +// in C++ anyway +#ifndef __cplusplus +#ifdef __APPLE__ +#include +typedef uint16_t char16_t; +typedef uint32_t char32_t; +#else +#include +#endif +#endif + + +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +typedef struct DiplomatWriteable { + void* context; + char* buf; + size_t len; + size_t cap; + void (*flush)(struct DiplomatWriteable*); + bool (*grow)(struct DiplomatWriteable*, size_t); +} DiplomatWriteable; + +DiplomatWriteable diplomat_simple_writeable(char* buf, size_t buf_size); + +typedef struct DiplomatStringView { + const char* data; + size_t len; +} DiplomatStringView; + +#define MAKE_SLICE_VIEW(name, c_ty) \ + typedef struct Diplomat##name##View { \ + const c_ty* data; \ + size_t len; \ + } Diplomat##name##View; + +MAKE_SLICE_VIEW(I8, int8_t) +MAKE_SLICE_VIEW(U8, uint8_t) +MAKE_SLICE_VIEW(I16, int16_t) +MAKE_SLICE_VIEW(U16, uint16_t) +MAKE_SLICE_VIEW(I32, int32_t) +MAKE_SLICE_VIEW(U32, uint32_t) +MAKE_SLICE_VIEW(I64, int64_t) +MAKE_SLICE_VIEW(U64, uint64_t) +MAKE_SLICE_VIEW(Isize, intptr_t) +MAKE_SLICE_VIEW(Usize, size_t) +MAKE_SLICE_VIEW(F32, float) +MAKE_SLICE_VIEW(F64, double) +MAKE_SLICE_VIEW(Bool, bool) +MAKE_SLICE_VIEW(Char, char32_t) + + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif + +#endif -- cgit v1.2.3