diff --git a/Cargo.lock b/Cargo.lock index 96780f2a9..421353eb5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -289,8 +289,9 @@ version = "0.0.16" [[package]] name = "diplomat" -version = "0.12.0" -source = "git+https://github.com/rust-diplomat/diplomat?rev=6d7c8746b126ea09230948a9c2f7c2de087624cc#6d7c8746b126ea09230948a9c2f7c2de087624cc" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ece782ffeb426ef0d3074c5623e8f6552cc912e4bbeecfda9583cb01b02b8ba1" dependencies = [ "diplomat_core", "proc-macro2", @@ -307,13 +308,15 @@ dependencies = [ [[package]] name = "diplomat-runtime" -version = "0.12.0" -source = "git+https://github.com/rust-diplomat/diplomat?rev=6d7c8746b126ea09230948a9c2f7c2de087624cc#6d7c8746b126ea09230948a9c2f7c2de087624cc" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa011f69b7f99cd4c4f1545a88cfa5f303abfdd76962843a5e5c88ea7bfe81f4" [[package]] name = "diplomat-tool" -version = "0.12.1" -source = "git+https://github.com/rust-diplomat/diplomat?rev=6d7c8746b126ea09230948a9c2f7c2de087624cc#6d7c8746b126ea09230948a9c2f7c2de087624cc" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f88fa2be520ed769c790accb955cc51ebc7ceb1e9d87ce4b7db24357e9378bad" dependencies = [ "askama", "clap", @@ -333,8 +336,9 @@ dependencies = [ [[package]] name = "diplomat_core" -version = "0.12.1" -source = "git+https://github.com/rust-diplomat/diplomat?rev=6d7c8746b126ea09230948a9c2f7c2de087624cc#6d7c8746b126ea09230948a9c2f7c2de087624cc" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb0f9322e2c506400ac3f374abfcaf9fd841fcdb729bbf008a135b600f99ede7" dependencies = [ "displaydoc", "either", diff --git a/Cargo.toml b/Cargo.toml index 0cf9e91a3..f2d72ca1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,9 +50,9 @@ zerovec = "0.11.4" zoneinfo64 = "0.2.0" # Diplomat -diplomat-tool = { git = "https://github.com/rust-diplomat/diplomat", rev = "6d7c8746b126ea09230948a9c2f7c2de087624cc", default-features = false } -diplomat-runtime = { git = "https://github.com/rust-diplomat/diplomat", rev = "6d7c8746b126ea09230948a9c2f7c2de087624cc", default-features = false } -diplomat = { git = "https://github.com/rust-diplomat/diplomat", rev = "6d7c8746b126ea09230948a9c2f7c2de087624cc", default-features = false } +diplomat-tool = { version = "0.13.0", default-features = false } +diplomat-runtime = { version = "0.13.0", default-features = false } +diplomat = { version = "0.13.0", default-features = false } [package] diff --git a/temporal_capi/bindings/cpp/temporal_rs/Calendar.d.hpp b/temporal_capi/bindings/cpp/temporal_rs/Calendar.d.hpp index 446f2bc7a..fe042ea08 100644 --- a/temporal_capi/bindings/cpp/temporal_rs/Calendar.d.hpp +++ b/temporal_capi/bindings/cpp/temporal_rs/Calendar.d.hpp @@ -41,9 +41,9 @@ class Calendar { inline std::string_view identifier() const; - /** - * Returns the kind of this calendar - */ + /** + * Returns the kind of this calendar + */ inline temporal_rs::AnyCalendarKind kind() const; inline const temporal_rs::capi::Calendar* AsFFI() const; diff --git a/temporal_capi/bindings/cpp/temporal_rs/Duration.d.hpp b/temporal_capi/bindings/cpp/temporal_rs/Duration.d.hpp index e529ad069..8357d229f 100644 --- a/temporal_capi/bindings/cpp/temporal_rs/Duration.d.hpp +++ b/temporal_capi/bindings/cpp/temporal_rs/Duration.d.hpp @@ -36,9 +36,9 @@ namespace temporal_rs { class Duration { public: - /** - * Temporary API until v8 can move off of it - */ + /** + * Temporary API until v8 can move off of it + */ inline static temporal_rs::diplomat::result, temporal_rs::TemporalError> create(int64_t years, int64_t months, int64_t weeks, int64_t days, int64_t hours, int64_t minutes, int64_t seconds, int64_t milliseconds, double microseconds, double nanoseconds); inline static temporal_rs::diplomat::result, temporal_rs::TemporalError> try_new(int64_t years, int64_t months, int64_t weeks, int64_t days, int64_t hours, int64_t minutes, int64_t seconds, int64_t milliseconds, double microseconds, double nanoseconds); diff --git a/temporal_capi/bindings/cpp/temporal_rs/Provider.d.hpp b/temporal_capi/bindings/cpp/temporal_rs/Provider.d.hpp index 00cd6c29f..f704677b4 100644 --- a/temporal_capi/bindings/cpp/temporal_rs/Provider.d.hpp +++ b/temporal_capi/bindings/cpp/temporal_rs/Provider.d.hpp @@ -30,18 +30,18 @@ namespace temporal_rs { class Provider { public: - /** - * Construct a provider backed by a zoneinfo64.res file - * - * This failing to construct is not a Temporal error, so it just returns () - */ + /** + * Construct a provider backed by a zoneinfo64.res file + * + * This failing to construct is not a Temporal error, so it just returns () + */ inline static temporal_rs::diplomat::result, std::monostate> new_zoneinfo64(temporal_rs::diplomat::span data); inline static std::unique_ptr new_compiled(); - /** - * Fallback type in case construction does not work. - */ + /** + * Fallback type in case construction does not work. + */ inline static std::unique_ptr empty(); inline const temporal_rs::capi::Provider* AsFFI() const; diff --git a/temporal_capi/bindings/cpp/temporal_rs/TimeZone.d.hpp b/temporal_capi/bindings/cpp/temporal_rs/TimeZone.d.hpp index 3cc21843d..46f31b1d4 100644 --- a/temporal_capi/bindings/cpp/temporal_rs/TimeZone.d.hpp +++ b/temporal_capi/bindings/cpp/temporal_rs/TimeZone.d.hpp @@ -67,17 +67,17 @@ struct TimeZone { inline static temporal_rs::diplomat::result utc_with_provider(const temporal_rs::Provider& p); - /** - * Create a TimeZone that represents +00:00 - * - * This is the only way to infallibly make a TimeZone without compiled_data, - * and can be used as a fallback. - */ + /** + * Create a TimeZone that represents +00:00 + * + * This is the only way to infallibly make a TimeZone without compiled_data, + * and can be used as a fallback. + */ inline static temporal_rs::TimeZone zero(); - /** - * Get the primary time zone identifier corresponding to this time zone - */ + /** + * Get the primary time zone identifier corresponding to this time zone + */ inline temporal_rs::diplomat::result primary_identifier() const; inline temporal_rs::diplomat::result primary_identifier_with_provider(const temporal_rs::Provider& p) const; diff --git a/temporal_capi/bindings/cpp/temporal_rs/diplomat_runtime.hpp b/temporal_capi/bindings/cpp/temporal_rs/diplomat_runtime.hpp index 1273ba545..1e32c8929 100644 --- a/temporal_capi/bindings/cpp/temporal_rs/diplomat_runtime.hpp +++ b/temporal_capi/bindings/cpp/temporal_rs/diplomat_runtime.hpp @@ -282,6 +282,68 @@ class span { #endif // __cplusplus >= 202002L +// An ABI stable std::basic_string_view equivalent for the case of string +// views in slices +template > +class basic_string_view_for_slice { +public: + using std_string_view = std::basic_string_view; + using traits_type = typename std_string_view::traits_type; + using value_type = typename std_string_view::value_type; + using pointer = typename std_string_view::pointer; + using const_pointer = typename std_string_view::const_pointer; + using size_type = typename std_string_view::size_type; + using difference_type = typename std_string_view::difference_type; + + constexpr basic_string_view_for_slice() noexcept + : basic_string_view_for_slice{std_string_view{}} {} + + constexpr basic_string_view_for_slice(const basic_string_view_for_slice& other) noexcept = default; + + constexpr basic_string_view_for_slice(const const_pointer s, const size_type count) + : basic_string_view_for_slice{std_string_view{s, count}} {} + + constexpr basic_string_view_for_slice(const const_pointer s) + : basic_string_view_for_slice{std_string_view{s}} {} + + constexpr basic_string_view_for_slice& operator=(const basic_string_view_for_slice& view) noexcept = default; + + constexpr basic_string_view_for_slice(const std_string_view& s) noexcept + : data_{s.data(), s.size()} {} + + constexpr basic_string_view_for_slice& operator=(const std_string_view& s) noexcept { + data_ = {s.data(), s.size()}; + return *this; + } + + constexpr operator std_string_view() const noexcept { return {data(), size()}; } + constexpr std_string_view as_sv() const noexcept { return *this; } + + constexpr const_pointer data() const noexcept { return data_.data; } + constexpr size_type size() const noexcept { return data_.len; } + +private: + using capi_type = + std::conditional_t, + capi::DiplomatStringView, + std::conditional_t, + capi::DiplomatString16View, + void>>; + + static_assert(!std::is_void_v, + "ABI compatible string_views are only supported for char and char16_t"); + + capi_type data_; +}; + +// We only implement these specialisations as diplomat doesn't provide c abi +// types for others +using string_view_for_slice = basic_string_view_for_slice; +using u16string_view_for_slice = basic_string_view_for_slice; + +using string_view_span = span; +using u16string_view_span = span; + // Interop between std::function & our C Callback wrapper type template