diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3ea503d78..97f2d7c48 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -124,8 +124,10 @@ jobs: - name: Check diff run: git diff --exit-code # Todo: eventually we should check in bindings and test them - - name: Makefile tests - run: cd temporal_capi/cpp_tests && make + - name: FFI tests + run: | + pushd temporal_capi/tests/c && make && popd + pushd temporal_capi/tests/cpp && make && popd # There's no guarantee that dependencies are no_std unless you test with a toolchain without `std` - name: Install no_std toolchain diff --git a/.gitignore b/.gitignore index 9d055f670..2c356aa23 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,7 @@ tzdata/ # Ignore log files *.log + +# Ignore clangd files +.cache +compile_commands.json diff --git a/Cargo.lock b/Cargo.lock index c5a300e22..a23df66b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,12 +61,12 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.7" +version = "3.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" +checksum = "6680de5231bd6ee4c6191b8a1325daa282b415391ec9d3a37bd34f2060dc73fa" dependencies = [ "anstyle", - "once_cell", + "once_cell_polyfill", "windows-sys", ] @@ -140,9 +140,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" [[package]] name = "bumpalo" @@ -168,9 +168,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.16" +version = "1.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" +checksum = "16595d3be041c03b09d08d0858631facccee9221e579704070e6e9e4915d3bc7" dependencies = [ "shlex", ] @@ -183,9 +183,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.32" +version = "4.5.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83" +checksum = "ed93b9805f8ba930df42c2590f05453d5ec36cbb85d018868a5b24d31f6ac000" dependencies = [ "clap_builder", "clap_derive", @@ -193,9 +193,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.32" +version = "4.5.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8" +checksum = "379026ff283facf611b0ea629334361c4211d1b12ee01024eec1591133b04120" dependencies = [ "anstream", "anstyle", @@ -571,15 +571,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.171" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "libm" -version = "0.2.11" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" [[package]] name = "litemap" @@ -613,9 +613,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.21.1" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" [[package]] name = "parse-zoneinfo" @@ -654,9 +660,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -726,9 +732,9 @@ checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustversion" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" +checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" [[package]] name = "ryu" @@ -785,9 +791,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "smallvec" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" [[package]] name = "stable_deref_trait" @@ -833,9 +839,9 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", @@ -1041,9 +1047,9 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.61.0" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ "windows-implement", "windows-interface", @@ -1082,18 +1088,18 @@ checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" [[package]] name = "windows-result" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" dependencies = [ "windows-link", ] [[package]] name = "windows-strings" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" dependencies = [ "windows-link", ] diff --git a/diplomat-gen/src/main.rs b/diplomat-gen/src/main.rs index 5ce001e31..ba23690a1 100644 --- a/diplomat-gen/src/main.rs +++ b/diplomat-gen/src/main.rs @@ -1,23 +1,35 @@ -use std::path::Path; +use std::{io, path::Path}; + +use diplomat_tool::config::Config; fn main() -> std::io::Result<()> { + const LANGUAGES: [&str; 2] = ["c", "cpp"]; + let manifest = Path::new(env!("CARGO_MANIFEST_DIR")); let capi = manifest.parent().unwrap().join("temporal_capi"); - let library_config = Default::default(); + let library_config = Config::default(); + + for lang in LANGUAGES { + diplomat_tool::gen( + &capi.join("src/lib.rs"), + lang, + &{ + let include = capi.join("bindings").join(lang); + if let Err(err) = std::fs::remove_dir_all(&include) { + if err.kind() != io::ErrorKind::NotFound { + return Err(err); + } + } + std::fs::create_dir(&include)?; + include + }, + &Default::default(), + library_config.clone(), + false, + )?; + } - diplomat_tool::gen( - &capi.join("src/lib.rs"), - "cpp", - &{ - let include = capi.join("bindings").join("cpp"); - std::fs::remove_dir_all(&include)?; - std::fs::create_dir(&include)?; - include - }, - &Default::default(), - library_config, - false, - ) + Ok(()) } diff --git a/temporal_capi/bindings/c/AnyCalendarKind.d.h b/temporal_capi/bindings/c/AnyCalendarKind.d.h new file mode 100644 index 000000000..44bed28e1 --- /dev/null +++ b/temporal_capi/bindings/c/AnyCalendarKind.d.h @@ -0,0 +1,39 @@ +#ifndef AnyCalendarKind_D_H +#define AnyCalendarKind_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef enum AnyCalendarKind { + AnyCalendarKind_Buddhist = 0, + AnyCalendarKind_Chinese = 1, + AnyCalendarKind_Coptic = 2, + AnyCalendarKind_Dangi = 3, + AnyCalendarKind_Ethiopian = 4, + AnyCalendarKind_EthiopianAmeteAlem = 5, + AnyCalendarKind_Gregorian = 6, + AnyCalendarKind_Hebrew = 7, + AnyCalendarKind_Indian = 8, + AnyCalendarKind_HijriTabularTypeIIFriday = 9, + AnyCalendarKind_HijriSimulatedMecca = 10, + AnyCalendarKind_HijriTabularTypeIIThursday = 11, + AnyCalendarKind_HijriUmmAlQura = 12, + AnyCalendarKind_Iso = 13, + AnyCalendarKind_Japanese = 14, + AnyCalendarKind_JapaneseExtended = 15, + AnyCalendarKind_Persian = 16, + AnyCalendarKind_Roc = 17, +} AnyCalendarKind; + +typedef struct AnyCalendarKind_option {union { AnyCalendarKind ok; }; bool is_ok; } AnyCalendarKind_option; + + + +#endif // AnyCalendarKind_D_H diff --git a/temporal_capi/bindings/c/AnyCalendarKind.h b/temporal_capi/bindings/c/AnyCalendarKind.h new file mode 100644 index 000000000..ddc2f6c12 --- /dev/null +++ b/temporal_capi/bindings/c/AnyCalendarKind.h @@ -0,0 +1,25 @@ +#ifndef AnyCalendarKind_H +#define AnyCalendarKind_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "AnyCalendarKind.d.h" + + + + + + +typedef struct temporal_rs_AnyCalendarKind_get_for_str_result {union {AnyCalendarKind ok; }; bool is_ok;} temporal_rs_AnyCalendarKind_get_for_str_result; +temporal_rs_AnyCalendarKind_get_for_str_result temporal_rs_AnyCalendarKind_get_for_str(DiplomatStringView s); + + + + + +#endif // AnyCalendarKind_H diff --git a/temporal_capi/bindings/c/ArithmeticOverflow.d.h b/temporal_capi/bindings/c/ArithmeticOverflow.d.h new file mode 100644 index 000000000..47d8f551a --- /dev/null +++ b/temporal_capi/bindings/c/ArithmeticOverflow.d.h @@ -0,0 +1,23 @@ +#ifndef ArithmeticOverflow_D_H +#define ArithmeticOverflow_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef enum ArithmeticOverflow { + ArithmeticOverflow_Constrain = 0, + ArithmeticOverflow_Reject = 1, +} ArithmeticOverflow; + +typedef struct ArithmeticOverflow_option {union { ArithmeticOverflow ok; }; bool is_ok; } ArithmeticOverflow_option; + + + +#endif // ArithmeticOverflow_D_H diff --git a/temporal_capi/bindings/c/ArithmeticOverflow.h b/temporal_capi/bindings/c/ArithmeticOverflow.h new file mode 100644 index 000000000..4406c69ff --- /dev/null +++ b/temporal_capi/bindings/c/ArithmeticOverflow.h @@ -0,0 +1,22 @@ +#ifndef ArithmeticOverflow_H +#define ArithmeticOverflow_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "ArithmeticOverflow.d.h" + + + + + + + + + + +#endif // ArithmeticOverflow_H diff --git a/temporal_capi/bindings/c/Calendar.d.h b/temporal_capi/bindings/c/Calendar.d.h new file mode 100644 index 000000000..d748ff0cb --- /dev/null +++ b/temporal_capi/bindings/c/Calendar.d.h @@ -0,0 +1,19 @@ +#ifndef Calendar_D_H +#define Calendar_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct Calendar Calendar; + + + + +#endif // Calendar_D_H diff --git a/temporal_capi/bindings/c/Calendar.h b/temporal_capi/bindings/c/Calendar.h new file mode 100644 index 000000000..062028ce7 --- /dev/null +++ b/temporal_capi/bindings/c/Calendar.h @@ -0,0 +1,95 @@ +#ifndef Calendar_H +#define Calendar_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "AnyCalendarKind.d.h" +#include "ArithmeticOverflow.d.h" +#include "Duration.d.h" +#include "IsoDate.d.h" +#include "PartialDate.d.h" +#include "PlainDate.d.h" +#include "PlainMonthDay.d.h" +#include "PlainYearMonth.d.h" +#include "TemporalError.d.h" +#include "Unit.d.h" + +#include "Calendar.d.h" + + + + + + +Calendar* temporal_rs_Calendar_create(AnyCalendarKind kind); + +typedef struct temporal_rs_Calendar_from_utf8_result {union {Calendar* ok; TemporalError err;}; bool is_ok;} temporal_rs_Calendar_from_utf8_result; +temporal_rs_Calendar_from_utf8_result temporal_rs_Calendar_from_utf8(DiplomatStringView s); + +bool temporal_rs_Calendar_is_iso(const Calendar* self); + +DiplomatStringView temporal_rs_Calendar_identifier(const Calendar* self); + +typedef struct temporal_rs_Calendar_date_from_partial_result {union {PlainDate* ok; TemporalError err;}; bool is_ok;} temporal_rs_Calendar_date_from_partial_result; +temporal_rs_Calendar_date_from_partial_result temporal_rs_Calendar_date_from_partial(const Calendar* self, PartialDate partial, ArithmeticOverflow overflow); + +typedef struct temporal_rs_Calendar_month_day_from_partial_result {union {PlainMonthDay* ok; TemporalError err;}; bool is_ok;} temporal_rs_Calendar_month_day_from_partial_result; +temporal_rs_Calendar_month_day_from_partial_result temporal_rs_Calendar_month_day_from_partial(const Calendar* self, PartialDate partial, ArithmeticOverflow overflow); + +typedef struct temporal_rs_Calendar_year_month_from_partial_result {union {PlainYearMonth* ok; TemporalError err;}; bool is_ok;} temporal_rs_Calendar_year_month_from_partial_result; +temporal_rs_Calendar_year_month_from_partial_result temporal_rs_Calendar_year_month_from_partial(const Calendar* self, PartialDate partial, ArithmeticOverflow overflow); + +typedef struct temporal_rs_Calendar_date_add_result {union {PlainDate* ok; TemporalError err;}; bool is_ok;} temporal_rs_Calendar_date_add_result; +temporal_rs_Calendar_date_add_result temporal_rs_Calendar_date_add(const Calendar* self, IsoDate date, const Duration* duration, ArithmeticOverflow overflow); + +typedef struct temporal_rs_Calendar_date_until_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_Calendar_date_until_result; +temporal_rs_Calendar_date_until_result temporal_rs_Calendar_date_until(const Calendar* self, IsoDate one, IsoDate two, Unit largest_unit); + +typedef struct temporal_rs_Calendar_era_result {union { TemporalError err;}; bool is_ok;} temporal_rs_Calendar_era_result; +temporal_rs_Calendar_era_result temporal_rs_Calendar_era(const Calendar* self, IsoDate date, DiplomatWrite* write); + +typedef struct temporal_rs_Calendar_era_year_result {union {int32_t ok; }; bool is_ok;} temporal_rs_Calendar_era_year_result; +temporal_rs_Calendar_era_year_result temporal_rs_Calendar_era_year(const Calendar* self, IsoDate date); + +int32_t temporal_rs_Calendar_year(const Calendar* self, IsoDate date); + +uint8_t temporal_rs_Calendar_month(const Calendar* self, IsoDate date); + +typedef struct temporal_rs_Calendar_month_code_result {union { TemporalError err;}; bool is_ok;} temporal_rs_Calendar_month_code_result; +temporal_rs_Calendar_month_code_result temporal_rs_Calendar_month_code(const Calendar* self, IsoDate date, DiplomatWrite* write); + +uint8_t temporal_rs_Calendar_day(const Calendar* self, IsoDate date); + +typedef struct temporal_rs_Calendar_day_of_week_result {union {uint16_t ok; TemporalError err;}; bool is_ok;} temporal_rs_Calendar_day_of_week_result; +temporal_rs_Calendar_day_of_week_result temporal_rs_Calendar_day_of_week(const Calendar* self, IsoDate date); + +uint16_t temporal_rs_Calendar_day_of_year(const Calendar* self, IsoDate date); + +typedef struct temporal_rs_Calendar_week_of_year_result {union {uint8_t ok; }; bool is_ok;} temporal_rs_Calendar_week_of_year_result; +temporal_rs_Calendar_week_of_year_result temporal_rs_Calendar_week_of_year(const Calendar* self, IsoDate date); + +typedef struct temporal_rs_Calendar_year_of_week_result {union {int32_t ok; }; bool is_ok;} temporal_rs_Calendar_year_of_week_result; +temporal_rs_Calendar_year_of_week_result temporal_rs_Calendar_year_of_week(const Calendar* self, IsoDate date); + +typedef struct temporal_rs_Calendar_days_in_week_result {union {uint16_t ok; TemporalError err;}; bool is_ok;} temporal_rs_Calendar_days_in_week_result; +temporal_rs_Calendar_days_in_week_result temporal_rs_Calendar_days_in_week(const Calendar* self, IsoDate date); + +uint16_t temporal_rs_Calendar_days_in_month(const Calendar* self, IsoDate date); + +uint16_t temporal_rs_Calendar_days_in_year(const Calendar* self, IsoDate date); + +uint16_t temporal_rs_Calendar_months_in_year(const Calendar* self, IsoDate date); + +bool temporal_rs_Calendar_in_leap_year(const Calendar* self, IsoDate date); + +void temporal_rs_Calendar_destroy(Calendar* self); + + + + + +#endif // Calendar_H diff --git a/temporal_capi/bindings/c/DateDuration.d.h b/temporal_capi/bindings/c/DateDuration.d.h new file mode 100644 index 000000000..b92c029df --- /dev/null +++ b/temporal_capi/bindings/c/DateDuration.d.h @@ -0,0 +1,19 @@ +#ifndef DateDuration_D_H +#define DateDuration_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct DateDuration DateDuration; + + + + +#endif // DateDuration_D_H diff --git a/temporal_capi/bindings/c/DateDuration.h b/temporal_capi/bindings/c/DateDuration.h new file mode 100644 index 000000000..9079e42de --- /dev/null +++ b/temporal_capi/bindings/c/DateDuration.h @@ -0,0 +1,35 @@ +#ifndef DateDuration_H +#define DateDuration_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "Sign.d.h" +#include "TemporalError.d.h" + +#include "DateDuration.d.h" + + + + + + +typedef struct temporal_rs_DateDuration_new_result {union {DateDuration* ok; TemporalError err;}; bool is_ok;} temporal_rs_DateDuration_new_result; +temporal_rs_DateDuration_new_result temporal_rs_DateDuration_new(int64_t years, int64_t months, int64_t weeks, int64_t days); + +DateDuration* temporal_rs_DateDuration_abs(const DateDuration* self); + +DateDuration* temporal_rs_DateDuration_negated(const DateDuration* self); + +Sign temporal_rs_DateDuration_sign(const DateDuration* self); + +void temporal_rs_DateDuration_destroy(DateDuration* self); + + + + + +#endif // DateDuration_H diff --git a/temporal_capi/bindings/c/DifferenceSettings.d.h b/temporal_capi/bindings/c/DifferenceSettings.d.h new file mode 100644 index 000000000..f738a6093 --- /dev/null +++ b/temporal_capi/bindings/c/DifferenceSettings.d.h @@ -0,0 +1,27 @@ +#ifndef DifferenceSettings_D_H +#define DifferenceSettings_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "RoundingMode.d.h" +#include "Unit.d.h" + + + + +typedef struct DifferenceSettings { + Unit_option largest_unit; + Unit_option smallest_unit; + RoundingMode_option rounding_mode; + OptionU32 increment; +} DifferenceSettings; + +typedef struct DifferenceSettings_option {union { DifferenceSettings ok; }; bool is_ok; } DifferenceSettings_option; + + + +#endif // DifferenceSettings_D_H diff --git a/temporal_capi/bindings/c/DifferenceSettings.h b/temporal_capi/bindings/c/DifferenceSettings.h new file mode 100644 index 000000000..c43fa6b9d --- /dev/null +++ b/temporal_capi/bindings/c/DifferenceSettings.h @@ -0,0 +1,22 @@ +#ifndef DifferenceSettings_H +#define DifferenceSettings_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "DifferenceSettings.d.h" + + + + + + + + + + +#endif // DifferenceSettings_H diff --git a/temporal_capi/bindings/c/Disambiguation.d.h b/temporal_capi/bindings/c/Disambiguation.d.h new file mode 100644 index 000000000..cfe99859b --- /dev/null +++ b/temporal_capi/bindings/c/Disambiguation.d.h @@ -0,0 +1,25 @@ +#ifndef Disambiguation_D_H +#define Disambiguation_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef enum Disambiguation { + Disambiguation_Compatible = 0, + Disambiguation_Earlier = 1, + Disambiguation_Later = 2, + Disambiguation_Reject = 3, +} Disambiguation; + +typedef struct Disambiguation_option {union { Disambiguation ok; }; bool is_ok; } Disambiguation_option; + + + +#endif // Disambiguation_D_H diff --git a/temporal_capi/bindings/c/Disambiguation.h b/temporal_capi/bindings/c/Disambiguation.h new file mode 100644 index 000000000..f4aeaa7d5 --- /dev/null +++ b/temporal_capi/bindings/c/Disambiguation.h @@ -0,0 +1,22 @@ +#ifndef Disambiguation_H +#define Disambiguation_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "Disambiguation.d.h" + + + + + + + + + + +#endif // Disambiguation_H diff --git a/temporal_capi/bindings/c/DisplayCalendar.d.h b/temporal_capi/bindings/c/DisplayCalendar.d.h new file mode 100644 index 000000000..5aca25e6d --- /dev/null +++ b/temporal_capi/bindings/c/DisplayCalendar.d.h @@ -0,0 +1,25 @@ +#ifndef DisplayCalendar_D_H +#define DisplayCalendar_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef enum DisplayCalendar { + DisplayCalendar_Auto = 0, + DisplayCalendar_Always = 1, + DisplayCalendar_Never = 2, + DisplayCalendar_Critical = 3, +} DisplayCalendar; + +typedef struct DisplayCalendar_option {union { DisplayCalendar ok; }; bool is_ok; } DisplayCalendar_option; + + + +#endif // DisplayCalendar_D_H diff --git a/temporal_capi/bindings/c/DisplayCalendar.h b/temporal_capi/bindings/c/DisplayCalendar.h new file mode 100644 index 000000000..1d80f822b --- /dev/null +++ b/temporal_capi/bindings/c/DisplayCalendar.h @@ -0,0 +1,22 @@ +#ifndef DisplayCalendar_H +#define DisplayCalendar_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "DisplayCalendar.d.h" + + + + + + + + + + +#endif // DisplayCalendar_H diff --git a/temporal_capi/bindings/c/DisplayOffset.d.h b/temporal_capi/bindings/c/DisplayOffset.d.h new file mode 100644 index 000000000..668e20d36 --- /dev/null +++ b/temporal_capi/bindings/c/DisplayOffset.d.h @@ -0,0 +1,23 @@ +#ifndef DisplayOffset_D_H +#define DisplayOffset_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef enum DisplayOffset { + DisplayOffset_Auto = 0, + DisplayOffset_Never = 1, +} DisplayOffset; + +typedef struct DisplayOffset_option {union { DisplayOffset ok; }; bool is_ok; } DisplayOffset_option; + + + +#endif // DisplayOffset_D_H diff --git a/temporal_capi/bindings/c/DisplayOffset.h b/temporal_capi/bindings/c/DisplayOffset.h new file mode 100644 index 000000000..e59ccac16 --- /dev/null +++ b/temporal_capi/bindings/c/DisplayOffset.h @@ -0,0 +1,22 @@ +#ifndef DisplayOffset_H +#define DisplayOffset_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "DisplayOffset.d.h" + + + + + + + + + + +#endif // DisplayOffset_H diff --git a/temporal_capi/bindings/c/DisplayTimeZone.d.h b/temporal_capi/bindings/c/DisplayTimeZone.d.h new file mode 100644 index 000000000..f9b743749 --- /dev/null +++ b/temporal_capi/bindings/c/DisplayTimeZone.d.h @@ -0,0 +1,24 @@ +#ifndef DisplayTimeZone_D_H +#define DisplayTimeZone_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef enum DisplayTimeZone { + DisplayTimeZone_Auto = 0, + DisplayTimeZone_Never = 1, + DisplayTimeZone_Critical = 2, +} DisplayTimeZone; + +typedef struct DisplayTimeZone_option {union { DisplayTimeZone ok; }; bool is_ok; } DisplayTimeZone_option; + + + +#endif // DisplayTimeZone_D_H diff --git a/temporal_capi/bindings/c/DisplayTimeZone.h b/temporal_capi/bindings/c/DisplayTimeZone.h new file mode 100644 index 000000000..736cd05c4 --- /dev/null +++ b/temporal_capi/bindings/c/DisplayTimeZone.h @@ -0,0 +1,22 @@ +#ifndef DisplayTimeZone_H +#define DisplayTimeZone_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "DisplayTimeZone.d.h" + + + + + + + + + + +#endif // DisplayTimeZone_H diff --git a/temporal_capi/bindings/c/Duration.d.h b/temporal_capi/bindings/c/Duration.d.h new file mode 100644 index 000000000..b44d57260 --- /dev/null +++ b/temporal_capi/bindings/c/Duration.d.h @@ -0,0 +1,19 @@ +#ifndef Duration_D_H +#define Duration_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct Duration Duration; + + + + +#endif // Duration_D_H diff --git a/temporal_capi/bindings/c/Duration.h b/temporal_capi/bindings/c/Duration.h new file mode 100644 index 000000000..004a4895c --- /dev/null +++ b/temporal_capi/bindings/c/Duration.h @@ -0,0 +1,88 @@ +#ifndef Duration_H +#define Duration_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "DateDuration.d.h" +#include "PartialDuration.d.h" +#include "Sign.d.h" +#include "TemporalError.d.h" +#include "TimeDuration.d.h" +#include "ToStringRoundingOptions.d.h" + +#include "Duration.d.h" + + + + + + +typedef struct temporal_rs_Duration_create_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_Duration_create_result; +temporal_rs_Duration_create_result temporal_rs_Duration_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); + +typedef struct temporal_rs_Duration_from_day_and_time_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_Duration_from_day_and_time_result; +temporal_rs_Duration_from_day_and_time_result temporal_rs_Duration_from_day_and_time(int64_t day, const TimeDuration* time); + +typedef struct temporal_rs_Duration_from_partial_duration_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_Duration_from_partial_duration_result; +temporal_rs_Duration_from_partial_duration_result temporal_rs_Duration_from_partial_duration(PartialDuration partial); + +typedef struct temporal_rs_Duration_from_utf8_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_Duration_from_utf8_result; +temporal_rs_Duration_from_utf8_result temporal_rs_Duration_from_utf8(DiplomatStringView s); + +typedef struct temporal_rs_Duration_from_utf16_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_Duration_from_utf16_result; +temporal_rs_Duration_from_utf16_result temporal_rs_Duration_from_utf16(DiplomatString16View s); + +bool temporal_rs_Duration_is_time_within_range(const Duration* self); + +const TimeDuration* temporal_rs_Duration_time(const Duration* self); + +const DateDuration* temporal_rs_Duration_date(const Duration* self); + +int64_t temporal_rs_Duration_years(const Duration* self); + +int64_t temporal_rs_Duration_months(const Duration* self); + +int64_t temporal_rs_Duration_weeks(const Duration* self); + +int64_t temporal_rs_Duration_days(const Duration* self); + +int64_t temporal_rs_Duration_hours(const Duration* self); + +int64_t temporal_rs_Duration_minutes(const Duration* self); + +int64_t temporal_rs_Duration_seconds(const Duration* self); + +int64_t temporal_rs_Duration_milliseconds(const Duration* self); + +double temporal_rs_Duration_microseconds(const Duration* self); + +double temporal_rs_Duration_nanoseconds(const Duration* self); + +Sign temporal_rs_Duration_sign(const Duration* self); + +bool temporal_rs_Duration_is_zero(const Duration* self); + +Duration* temporal_rs_Duration_abs(const Duration* self); + +Duration* temporal_rs_Duration_negated(const Duration* self); + +typedef struct temporal_rs_Duration_add_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_Duration_add_result; +temporal_rs_Duration_add_result temporal_rs_Duration_add(const Duration* self, const Duration* other); + +typedef struct temporal_rs_Duration_subtract_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_Duration_subtract_result; +temporal_rs_Duration_subtract_result temporal_rs_Duration_subtract(const Duration* self, const Duration* other); + +typedef struct temporal_rs_Duration_to_string_result {union { TemporalError err;}; bool is_ok;} temporal_rs_Duration_to_string_result; +temporal_rs_Duration_to_string_result temporal_rs_Duration_to_string(const Duration* self, ToStringRoundingOptions options, DiplomatWrite* write); + +void temporal_rs_Duration_destroy(Duration* self); + + + + + +#endif // Duration_H diff --git a/temporal_capi/bindings/c/DurationOverflow.d.h b/temporal_capi/bindings/c/DurationOverflow.d.h new file mode 100644 index 000000000..d8be690f2 --- /dev/null +++ b/temporal_capi/bindings/c/DurationOverflow.d.h @@ -0,0 +1,23 @@ +#ifndef DurationOverflow_D_H +#define DurationOverflow_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef enum DurationOverflow { + DurationOverflow_Constrain = 0, + DurationOverflow_Balance = 1, +} DurationOverflow; + +typedef struct DurationOverflow_option {union { DurationOverflow ok; }; bool is_ok; } DurationOverflow_option; + + + +#endif // DurationOverflow_D_H diff --git a/temporal_capi/bindings/c/DurationOverflow.h b/temporal_capi/bindings/c/DurationOverflow.h new file mode 100644 index 000000000..54e133748 --- /dev/null +++ b/temporal_capi/bindings/c/DurationOverflow.h @@ -0,0 +1,22 @@ +#ifndef DurationOverflow_H +#define DurationOverflow_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "DurationOverflow.d.h" + + + + + + + + + + +#endif // DurationOverflow_H diff --git a/temporal_capi/bindings/c/ErrorKind.d.h b/temporal_capi/bindings/c/ErrorKind.d.h new file mode 100644 index 000000000..946194415 --- /dev/null +++ b/temporal_capi/bindings/c/ErrorKind.d.h @@ -0,0 +1,26 @@ +#ifndef ErrorKind_D_H +#define ErrorKind_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef enum ErrorKind { + ErrorKind_Generic = 0, + ErrorKind_Type = 1, + ErrorKind_Range = 2, + ErrorKind_Syntax = 3, + ErrorKind_Assert = 4, +} ErrorKind; + +typedef struct ErrorKind_option {union { ErrorKind ok; }; bool is_ok; } ErrorKind_option; + + + +#endif // ErrorKind_D_H diff --git a/temporal_capi/bindings/c/ErrorKind.h b/temporal_capi/bindings/c/ErrorKind.h new file mode 100644 index 000000000..113613977 --- /dev/null +++ b/temporal_capi/bindings/c/ErrorKind.h @@ -0,0 +1,22 @@ +#ifndef ErrorKind_H +#define ErrorKind_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "ErrorKind.d.h" + + + + + + + + + + +#endif // ErrorKind_H diff --git a/temporal_capi/bindings/c/I128Nanoseconds.d.h b/temporal_capi/bindings/c/I128Nanoseconds.d.h new file mode 100644 index 000000000..e1cc2181b --- /dev/null +++ b/temporal_capi/bindings/c/I128Nanoseconds.d.h @@ -0,0 +1,23 @@ +#ifndef I128Nanoseconds_D_H +#define I128Nanoseconds_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct I128Nanoseconds { + int64_t high; + uint64_t low; +} I128Nanoseconds; + +typedef struct I128Nanoseconds_option {union { I128Nanoseconds ok; }; bool is_ok; } I128Nanoseconds_option; + + + +#endif // I128Nanoseconds_D_H diff --git a/temporal_capi/bindings/c/I128Nanoseconds.h b/temporal_capi/bindings/c/I128Nanoseconds.h new file mode 100644 index 000000000..4ac54898f --- /dev/null +++ b/temporal_capi/bindings/c/I128Nanoseconds.h @@ -0,0 +1,22 @@ +#ifndef I128Nanoseconds_H +#define I128Nanoseconds_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "I128Nanoseconds.d.h" + + + + + + + + + + +#endif // I128Nanoseconds_H diff --git a/temporal_capi/bindings/c/Instant.d.h b/temporal_capi/bindings/c/Instant.d.h new file mode 100644 index 000000000..77d95421e --- /dev/null +++ b/temporal_capi/bindings/c/Instant.d.h @@ -0,0 +1,19 @@ +#ifndef Instant_D_H +#define Instant_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct Instant Instant; + + + + +#endif // Instant_D_H diff --git a/temporal_capi/bindings/c/Instant.h b/temporal_capi/bindings/c/Instant.h new file mode 100644 index 000000000..e3f3d7e52 --- /dev/null +++ b/temporal_capi/bindings/c/Instant.h @@ -0,0 +1,76 @@ +#ifndef Instant_H +#define Instant_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "DifferenceSettings.d.h" +#include "Duration.d.h" +#include "I128Nanoseconds.d.h" +#include "RoundingOptions.d.h" +#include "TemporalError.d.h" +#include "TimeDuration.d.h" +#include "TimeZone.d.h" +#include "ToStringRoundingOptions.d.h" + +#include "Instant.d.h" + + + + + + +typedef struct temporal_rs_Instant_try_new_result {union {Instant* ok; TemporalError err;}; bool is_ok;} temporal_rs_Instant_try_new_result; +temporal_rs_Instant_try_new_result temporal_rs_Instant_try_new(I128Nanoseconds ns); + +typedef struct temporal_rs_Instant_from_epoch_milliseconds_result {union {Instant* ok; TemporalError err;}; bool is_ok;} temporal_rs_Instant_from_epoch_milliseconds_result; +temporal_rs_Instant_from_epoch_milliseconds_result temporal_rs_Instant_from_epoch_milliseconds(int64_t epoch_milliseconds); + +typedef struct temporal_rs_Instant_from_utf8_result {union {Instant* ok; TemporalError err;}; bool is_ok;} temporal_rs_Instant_from_utf8_result; +temporal_rs_Instant_from_utf8_result temporal_rs_Instant_from_utf8(DiplomatStringView s); + +typedef struct temporal_rs_Instant_from_utf16_result {union {Instant* ok; TemporalError err;}; bool is_ok;} temporal_rs_Instant_from_utf16_result; +temporal_rs_Instant_from_utf16_result temporal_rs_Instant_from_utf16(DiplomatString16View s); + +typedef struct temporal_rs_Instant_add_result {union {Instant* ok; TemporalError err;}; bool is_ok;} temporal_rs_Instant_add_result; +temporal_rs_Instant_add_result temporal_rs_Instant_add(const Instant* self, const Duration* duration); + +typedef struct temporal_rs_Instant_add_time_duration_result {union {Instant* ok; TemporalError err;}; bool is_ok;} temporal_rs_Instant_add_time_duration_result; +temporal_rs_Instant_add_time_duration_result temporal_rs_Instant_add_time_duration(const Instant* self, const TimeDuration* duration); + +typedef struct temporal_rs_Instant_subtract_result {union {Instant* ok; TemporalError err;}; bool is_ok;} temporal_rs_Instant_subtract_result; +temporal_rs_Instant_subtract_result temporal_rs_Instant_subtract(const Instant* self, const Duration* duration); + +typedef struct temporal_rs_Instant_subtract_time_duration_result {union {Instant* ok; TemporalError err;}; bool is_ok;} temporal_rs_Instant_subtract_time_duration_result; +temporal_rs_Instant_subtract_time_duration_result temporal_rs_Instant_subtract_time_duration(const Instant* self, const TimeDuration* duration); + +typedef struct temporal_rs_Instant_since_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_Instant_since_result; +temporal_rs_Instant_since_result temporal_rs_Instant_since(const Instant* self, const Instant* other, DifferenceSettings settings); + +typedef struct temporal_rs_Instant_until_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_Instant_until_result; +temporal_rs_Instant_until_result temporal_rs_Instant_until(const Instant* self, const Instant* other, DifferenceSettings settings); + +typedef struct temporal_rs_Instant_round_result {union {Instant* ok; TemporalError err;}; bool is_ok;} temporal_rs_Instant_round_result; +temporal_rs_Instant_round_result temporal_rs_Instant_round(const Instant* self, RoundingOptions options); + +int8_t temporal_rs_Instant_compare(const Instant* self, const Instant* other); + +bool temporal_rs_Instant_equals(const Instant* self, const Instant* other); + +int64_t temporal_rs_Instant_epoch_milliseconds(const Instant* self); + +I128Nanoseconds temporal_rs_Instant_epoch_nanoseconds(const Instant* self); + +typedef struct temporal_rs_Instant_to_ixdtf_string_with_compiled_data_result {union { TemporalError err;}; bool is_ok;} temporal_rs_Instant_to_ixdtf_string_with_compiled_data_result; +temporal_rs_Instant_to_ixdtf_string_with_compiled_data_result temporal_rs_Instant_to_ixdtf_string_with_compiled_data(const Instant* self, const TimeZone* zone, ToStringRoundingOptions options, DiplomatWrite* write); + +void temporal_rs_Instant_destroy(Instant* self); + + + + + +#endif // Instant_H diff --git a/temporal_capi/bindings/c/IsoDate.d.h b/temporal_capi/bindings/c/IsoDate.d.h new file mode 100644 index 000000000..d449d0306 --- /dev/null +++ b/temporal_capi/bindings/c/IsoDate.d.h @@ -0,0 +1,24 @@ +#ifndef IsoDate_D_H +#define IsoDate_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct IsoDate { + int32_t year; + uint8_t month; + uint8_t day; +} IsoDate; + +typedef struct IsoDate_option {union { IsoDate ok; }; bool is_ok; } IsoDate_option; + + + +#endif // IsoDate_D_H diff --git a/temporal_capi/bindings/c/IsoDate.h b/temporal_capi/bindings/c/IsoDate.h new file mode 100644 index 000000000..41623a4aa --- /dev/null +++ b/temporal_capi/bindings/c/IsoDate.h @@ -0,0 +1,22 @@ +#ifndef IsoDate_H +#define IsoDate_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "IsoDate.d.h" + + + + + + + + + + +#endif // IsoDate_H diff --git a/temporal_capi/bindings/c/IsoDateTime.d.h b/temporal_capi/bindings/c/IsoDateTime.d.h new file mode 100644 index 000000000..8897b12fb --- /dev/null +++ b/temporal_capi/bindings/c/IsoDateTime.d.h @@ -0,0 +1,25 @@ +#ifndef IsoDateTime_D_H +#define IsoDateTime_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "IsoDate.d.h" +#include "IsoTime.d.h" + + + + +typedef struct IsoDateTime { + IsoDate date; + IsoTime time; +} IsoDateTime; + +typedef struct IsoDateTime_option {union { IsoDateTime ok; }; bool is_ok; } IsoDateTime_option; + + + +#endif // IsoDateTime_D_H diff --git a/temporal_capi/bindings/c/IsoDateTime.h b/temporal_capi/bindings/c/IsoDateTime.h new file mode 100644 index 000000000..67084542a --- /dev/null +++ b/temporal_capi/bindings/c/IsoDateTime.h @@ -0,0 +1,22 @@ +#ifndef IsoDateTime_H +#define IsoDateTime_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "IsoDateTime.d.h" + + + + + + + + + + +#endif // IsoDateTime_H diff --git a/temporal_capi/bindings/c/IsoTime.d.h b/temporal_capi/bindings/c/IsoTime.d.h new file mode 100644 index 000000000..0df066ba3 --- /dev/null +++ b/temporal_capi/bindings/c/IsoTime.d.h @@ -0,0 +1,27 @@ +#ifndef IsoTime_D_H +#define IsoTime_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct IsoTime { + uint8_t hour; + uint8_t minute; + uint8_t second; + uint16_t millisecond; + uint16_t microsecond; + uint16_t nanosecond; +} IsoTime; + +typedef struct IsoTime_option {union { IsoTime ok; }; bool is_ok; } IsoTime_option; + + + +#endif // IsoTime_D_H diff --git a/temporal_capi/bindings/c/IsoTime.h b/temporal_capi/bindings/c/IsoTime.h new file mode 100644 index 000000000..e382a8edc --- /dev/null +++ b/temporal_capi/bindings/c/IsoTime.h @@ -0,0 +1,22 @@ +#ifndef IsoTime_H +#define IsoTime_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "IsoTime.d.h" + + + + + + + + + + +#endif // IsoTime_H diff --git a/temporal_capi/bindings/c/OffsetDisambiguation.d.h b/temporal_capi/bindings/c/OffsetDisambiguation.d.h new file mode 100644 index 000000000..aa46cf3de --- /dev/null +++ b/temporal_capi/bindings/c/OffsetDisambiguation.d.h @@ -0,0 +1,25 @@ +#ifndef OffsetDisambiguation_D_H +#define OffsetDisambiguation_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef enum OffsetDisambiguation { + OffsetDisambiguation_Use = 0, + OffsetDisambiguation_Prefer = 1, + OffsetDisambiguation_Ignore = 2, + OffsetDisambiguation_Reject = 3, +} OffsetDisambiguation; + +typedef struct OffsetDisambiguation_option {union { OffsetDisambiguation ok; }; bool is_ok; } OffsetDisambiguation_option; + + + +#endif // OffsetDisambiguation_D_H diff --git a/temporal_capi/bindings/c/OffsetDisambiguation.h b/temporal_capi/bindings/c/OffsetDisambiguation.h new file mode 100644 index 000000000..8227ec084 --- /dev/null +++ b/temporal_capi/bindings/c/OffsetDisambiguation.h @@ -0,0 +1,22 @@ +#ifndef OffsetDisambiguation_H +#define OffsetDisambiguation_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "OffsetDisambiguation.d.h" + + + + + + + + + + +#endif // OffsetDisambiguation_H diff --git a/temporal_capi/bindings/c/PartialDate.d.h b/temporal_capi/bindings/c/PartialDate.d.h new file mode 100644 index 000000000..5f0b0ed7e --- /dev/null +++ b/temporal_capi/bindings/c/PartialDate.d.h @@ -0,0 +1,29 @@ +#ifndef PartialDate_D_H +#define PartialDate_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "Calendar.d.h" + + + + +typedef struct PartialDate { + OptionI32 year; + OptionU8 month; + DiplomatStringView month_code; + OptionU8 day; + DiplomatStringView era; + OptionI32 era_year; + const Calendar* calendar; +} PartialDate; + +typedef struct PartialDate_option {union { PartialDate ok; }; bool is_ok; } PartialDate_option; + + + +#endif // PartialDate_D_H diff --git a/temporal_capi/bindings/c/PartialDate.h b/temporal_capi/bindings/c/PartialDate.h new file mode 100644 index 000000000..824a8e034 --- /dev/null +++ b/temporal_capi/bindings/c/PartialDate.h @@ -0,0 +1,22 @@ +#ifndef PartialDate_H +#define PartialDate_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "PartialDate.d.h" + + + + + + + + + + +#endif // PartialDate_H diff --git a/temporal_capi/bindings/c/PartialDateTime.d.h b/temporal_capi/bindings/c/PartialDateTime.d.h new file mode 100644 index 000000000..735baf3fc --- /dev/null +++ b/temporal_capi/bindings/c/PartialDateTime.d.h @@ -0,0 +1,25 @@ +#ifndef PartialDateTime_D_H +#define PartialDateTime_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "PartialDate.d.h" +#include "PartialTime.d.h" + + + + +typedef struct PartialDateTime { + PartialDate date; + PartialTime time; +} PartialDateTime; + +typedef struct PartialDateTime_option {union { PartialDateTime ok; }; bool is_ok; } PartialDateTime_option; + + + +#endif // PartialDateTime_D_H diff --git a/temporal_capi/bindings/c/PartialDateTime.h b/temporal_capi/bindings/c/PartialDateTime.h new file mode 100644 index 000000000..11efc7104 --- /dev/null +++ b/temporal_capi/bindings/c/PartialDateTime.h @@ -0,0 +1,22 @@ +#ifndef PartialDateTime_H +#define PartialDateTime_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "PartialDateTime.d.h" + + + + + + + + + + +#endif // PartialDateTime_H diff --git a/temporal_capi/bindings/c/PartialDuration.d.h b/temporal_capi/bindings/c/PartialDuration.d.h new file mode 100644 index 000000000..f0189fc9a --- /dev/null +++ b/temporal_capi/bindings/c/PartialDuration.d.h @@ -0,0 +1,31 @@ +#ifndef PartialDuration_D_H +#define PartialDuration_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct PartialDuration { + OptionI64 years; + OptionI64 months; + OptionI64 weeks; + OptionI64 days; + OptionI64 hours; + OptionI64 minutes; + OptionI64 seconds; + OptionI64 milliseconds; + OptionF64 microseconds; + OptionF64 nanoseconds; +} PartialDuration; + +typedef struct PartialDuration_option {union { PartialDuration ok; }; bool is_ok; } PartialDuration_option; + + + +#endif // PartialDuration_D_H diff --git a/temporal_capi/bindings/c/PartialDuration.h b/temporal_capi/bindings/c/PartialDuration.h new file mode 100644 index 000000000..afe0bfb00 --- /dev/null +++ b/temporal_capi/bindings/c/PartialDuration.h @@ -0,0 +1,24 @@ +#ifndef PartialDuration_H +#define PartialDuration_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "PartialDuration.d.h" + + + + + + +bool temporal_rs_PartialDuration_is_empty(PartialDuration self); + + + + + +#endif // PartialDuration_H diff --git a/temporal_capi/bindings/c/PartialTime.d.h b/temporal_capi/bindings/c/PartialTime.d.h new file mode 100644 index 000000000..6dd1fe9be --- /dev/null +++ b/temporal_capi/bindings/c/PartialTime.d.h @@ -0,0 +1,27 @@ +#ifndef PartialTime_D_H +#define PartialTime_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct PartialTime { + OptionU8 hour; + OptionU8 minute; + OptionU8 second; + OptionU16 millisecond; + OptionU16 microsecond; + OptionU16 nanosecond; +} PartialTime; + +typedef struct PartialTime_option {union { PartialTime ok; }; bool is_ok; } PartialTime_option; + + + +#endif // PartialTime_D_H diff --git a/temporal_capi/bindings/c/PartialTime.h b/temporal_capi/bindings/c/PartialTime.h new file mode 100644 index 000000000..8662bb27a --- /dev/null +++ b/temporal_capi/bindings/c/PartialTime.h @@ -0,0 +1,22 @@ +#ifndef PartialTime_H +#define PartialTime_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "PartialTime.d.h" + + + + + + + + + + +#endif // PartialTime_H diff --git a/temporal_capi/bindings/c/PlainDate.d.h b/temporal_capi/bindings/c/PlainDate.d.h new file mode 100644 index 000000000..680fa1e83 --- /dev/null +++ b/temporal_capi/bindings/c/PlainDate.d.h @@ -0,0 +1,19 @@ +#ifndef PlainDate_D_H +#define PlainDate_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct PlainDate PlainDate; + + + + +#endif // PlainDate_D_H diff --git a/temporal_capi/bindings/c/PlainDate.h b/temporal_capi/bindings/c/PlainDate.h new file mode 100644 index 000000000..eb1ae040d --- /dev/null +++ b/temporal_capi/bindings/c/PlainDate.h @@ -0,0 +1,131 @@ +#ifndef PlainDate_H +#define PlainDate_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ArithmeticOverflow.d.h" +#include "Calendar.d.h" +#include "DifferenceSettings.d.h" +#include "DisplayCalendar.d.h" +#include "Duration.d.h" +#include "PartialDate.d.h" +#include "PlainDateTime.d.h" +#include "PlainMonthDay.d.h" +#include "PlainTime.d.h" +#include "PlainYearMonth.d.h" +#include "TemporalError.d.h" + +#include "PlainDate.d.h" + + + + + + +typedef struct temporal_rs_PlainDate_create_result {union {PlainDate* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_create_result; +temporal_rs_PlainDate_create_result temporal_rs_PlainDate_create(int32_t year, uint8_t month, uint8_t day, const Calendar* calendar); + +typedef struct temporal_rs_PlainDate_try_create_result {union {PlainDate* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_try_create_result; +temporal_rs_PlainDate_try_create_result temporal_rs_PlainDate_try_create(int32_t year, uint8_t month, uint8_t day, const Calendar* calendar); + +typedef struct temporal_rs_PlainDate_create_with_overflow_result {union {PlainDate* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_create_with_overflow_result; +temporal_rs_PlainDate_create_with_overflow_result temporal_rs_PlainDate_create_with_overflow(int32_t year, uint8_t month, uint8_t day, const Calendar* calendar, ArithmeticOverflow overflow); + +typedef struct temporal_rs_PlainDate_from_partial_result {union {PlainDate* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_from_partial_result; +temporal_rs_PlainDate_from_partial_result temporal_rs_PlainDate_from_partial(PartialDate partial, ArithmeticOverflow_option overflow); + +typedef struct temporal_rs_PlainDate_with_result {union {PlainDate* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_with_result; +temporal_rs_PlainDate_with_result temporal_rs_PlainDate_with(const PlainDate* self, PartialDate partial, ArithmeticOverflow_option overflow); + +typedef struct temporal_rs_PlainDate_with_calendar_result {union {PlainDate* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_with_calendar_result; +temporal_rs_PlainDate_with_calendar_result temporal_rs_PlainDate_with_calendar(const PlainDate* self, const Calendar* calendar); + +typedef struct temporal_rs_PlainDate_from_utf8_result {union {PlainDate* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_from_utf8_result; +temporal_rs_PlainDate_from_utf8_result temporal_rs_PlainDate_from_utf8(DiplomatStringView s); + +typedef struct temporal_rs_PlainDate_from_utf16_result {union {PlainDate* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_from_utf16_result; +temporal_rs_PlainDate_from_utf16_result temporal_rs_PlainDate_from_utf16(DiplomatString16View s); + +int32_t temporal_rs_PlainDate_iso_year(const PlainDate* self); + +uint8_t temporal_rs_PlainDate_iso_month(const PlainDate* self); + +uint8_t temporal_rs_PlainDate_iso_day(const PlainDate* self); + +const Calendar* temporal_rs_PlainDate_calendar(const PlainDate* self); + +bool temporal_rs_PlainDate_is_valid(const PlainDate* self); + +typedef struct temporal_rs_PlainDate_add_result {union {PlainDate* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_add_result; +temporal_rs_PlainDate_add_result temporal_rs_PlainDate_add(const PlainDate* self, const Duration* duration, ArithmeticOverflow_option overflow); + +typedef struct temporal_rs_PlainDate_subtract_result {union {PlainDate* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_subtract_result; +temporal_rs_PlainDate_subtract_result temporal_rs_PlainDate_subtract(const PlainDate* self, const Duration* duration, ArithmeticOverflow_option overflow); + +typedef struct temporal_rs_PlainDate_until_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_until_result; +temporal_rs_PlainDate_until_result temporal_rs_PlainDate_until(const PlainDate* self, const PlainDate* other, DifferenceSettings settings); + +typedef struct temporal_rs_PlainDate_since_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_since_result; +temporal_rs_PlainDate_since_result temporal_rs_PlainDate_since(const PlainDate* self, const PlainDate* other, DifferenceSettings settings); + +bool temporal_rs_PlainDate_equals(const PlainDate* self, const PlainDate* other); + +int8_t temporal_rs_PlainDate_compare(const PlainDate* one, const PlainDate* two); + +int32_t temporal_rs_PlainDate_year(const PlainDate* self); + +uint8_t temporal_rs_PlainDate_month(const PlainDate* self); + +void temporal_rs_PlainDate_month_code(const PlainDate* self, DiplomatWrite* write); + +uint8_t temporal_rs_PlainDate_day(const PlainDate* self); + +typedef struct temporal_rs_PlainDate_day_of_week_result {union {uint16_t ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_day_of_week_result; +temporal_rs_PlainDate_day_of_week_result temporal_rs_PlainDate_day_of_week(const PlainDate* self); + +uint16_t temporal_rs_PlainDate_day_of_year(const PlainDate* self); + +typedef struct temporal_rs_PlainDate_week_of_year_result {union {uint8_t ok; }; bool is_ok;} temporal_rs_PlainDate_week_of_year_result; +temporal_rs_PlainDate_week_of_year_result temporal_rs_PlainDate_week_of_year(const PlainDate* self); + +typedef struct temporal_rs_PlainDate_year_of_week_result {union {int32_t ok; }; bool is_ok;} temporal_rs_PlainDate_year_of_week_result; +temporal_rs_PlainDate_year_of_week_result temporal_rs_PlainDate_year_of_week(const PlainDate* self); + +typedef struct temporal_rs_PlainDate_days_in_week_result {union {uint16_t ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_days_in_week_result; +temporal_rs_PlainDate_days_in_week_result temporal_rs_PlainDate_days_in_week(const PlainDate* self); + +uint16_t temporal_rs_PlainDate_days_in_month(const PlainDate* self); + +uint16_t temporal_rs_PlainDate_days_in_year(const PlainDate* self); + +uint16_t temporal_rs_PlainDate_months_in_year(const PlainDate* self); + +bool temporal_rs_PlainDate_in_leap_year(const PlainDate* self); + +void temporal_rs_PlainDate_era(const PlainDate* self, DiplomatWrite* write); + +typedef struct temporal_rs_PlainDate_era_year_result {union {int32_t ok; }; bool is_ok;} temporal_rs_PlainDate_era_year_result; +temporal_rs_PlainDate_era_year_result temporal_rs_PlainDate_era_year(const PlainDate* self); + +typedef struct temporal_rs_PlainDate_to_plain_date_time_result {union {PlainDateTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_to_plain_date_time_result; +temporal_rs_PlainDate_to_plain_date_time_result temporal_rs_PlainDate_to_plain_date_time(const PlainDate* self, const PlainTime* time); + +typedef struct temporal_rs_PlainDate_to_plain_month_day_result {union {PlainMonthDay* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_to_plain_month_day_result; +temporal_rs_PlainDate_to_plain_month_day_result temporal_rs_PlainDate_to_plain_month_day(const PlainDate* self); + +typedef struct temporal_rs_PlainDate_to_plain_year_month_result {union {PlainYearMonth* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDate_to_plain_year_month_result; +temporal_rs_PlainDate_to_plain_year_month_result temporal_rs_PlainDate_to_plain_year_month(const PlainDate* self); + +void temporal_rs_PlainDate_to_ixdtf_string(const PlainDate* self, DisplayCalendar display_calendar, DiplomatWrite* write); + +void temporal_rs_PlainDate_destroy(PlainDate* self); + + + + + +#endif // PlainDate_H diff --git a/temporal_capi/bindings/c/PlainDateTime.d.h b/temporal_capi/bindings/c/PlainDateTime.d.h new file mode 100644 index 000000000..83eafb5e8 --- /dev/null +++ b/temporal_capi/bindings/c/PlainDateTime.d.h @@ -0,0 +1,19 @@ +#ifndef PlainDateTime_D_H +#define PlainDateTime_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct PlainDateTime PlainDateTime; + + + + +#endif // PlainDateTime_D_H diff --git a/temporal_capi/bindings/c/PlainDateTime.h b/temporal_capi/bindings/c/PlainDateTime.h new file mode 100644 index 000000000..58b040d45 --- /dev/null +++ b/temporal_capi/bindings/c/PlainDateTime.h @@ -0,0 +1,142 @@ +#ifndef PlainDateTime_H +#define PlainDateTime_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ArithmeticOverflow.d.h" +#include "Calendar.d.h" +#include "DifferenceSettings.d.h" +#include "DisplayCalendar.d.h" +#include "Duration.d.h" +#include "PartialDateTime.d.h" +#include "PlainDate.d.h" +#include "PlainTime.d.h" +#include "RoundingOptions.d.h" +#include "TemporalError.d.h" +#include "ToStringRoundingOptions.d.h" + +#include "PlainDateTime.d.h" + + + + + + +typedef struct temporal_rs_PlainDateTime_create_result {union {PlainDateTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_create_result; +temporal_rs_PlainDateTime_create_result temporal_rs_PlainDateTime_create(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint16_t millisecond, uint16_t microsecond, uint16_t nanosecond, const Calendar* calendar); + +typedef struct temporal_rs_PlainDateTime_try_create_result {union {PlainDateTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_try_create_result; +temporal_rs_PlainDateTime_try_create_result temporal_rs_PlainDateTime_try_create(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint16_t millisecond, uint16_t microsecond, uint16_t nanosecond, const Calendar* calendar); + +typedef struct temporal_rs_PlainDateTime_from_partial_result {union {PlainDateTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_from_partial_result; +temporal_rs_PlainDateTime_from_partial_result temporal_rs_PlainDateTime_from_partial(PartialDateTime partial, ArithmeticOverflow_option overflow); + +typedef struct temporal_rs_PlainDateTime_with_result {union {PlainDateTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_with_result; +temporal_rs_PlainDateTime_with_result temporal_rs_PlainDateTime_with(const PlainDateTime* self, PartialDateTime partial, ArithmeticOverflow_option overflow); + +typedef struct temporal_rs_PlainDateTime_with_time_result {union {PlainDateTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_with_time_result; +temporal_rs_PlainDateTime_with_time_result temporal_rs_PlainDateTime_with_time(const PlainDateTime* self, const PlainTime* time); + +typedef struct temporal_rs_PlainDateTime_with_calendar_result {union {PlainDateTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_with_calendar_result; +temporal_rs_PlainDateTime_with_calendar_result temporal_rs_PlainDateTime_with_calendar(const PlainDateTime* self, const Calendar* calendar); + +typedef struct temporal_rs_PlainDateTime_from_utf8_result {union {PlainDateTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_from_utf8_result; +temporal_rs_PlainDateTime_from_utf8_result temporal_rs_PlainDateTime_from_utf8(DiplomatStringView s); + +typedef struct temporal_rs_PlainDateTime_from_utf16_result {union {PlainDateTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_from_utf16_result; +temporal_rs_PlainDateTime_from_utf16_result temporal_rs_PlainDateTime_from_utf16(DiplomatString16View s); + +int32_t temporal_rs_PlainDateTime_iso_year(const PlainDateTime* self); + +uint8_t temporal_rs_PlainDateTime_iso_month(const PlainDateTime* self); + +uint8_t temporal_rs_PlainDateTime_iso_day(const PlainDateTime* self); + +uint8_t temporal_rs_PlainDateTime_hour(const PlainDateTime* self); + +uint8_t temporal_rs_PlainDateTime_minute(const PlainDateTime* self); + +uint8_t temporal_rs_PlainDateTime_second(const PlainDateTime* self); + +uint16_t temporal_rs_PlainDateTime_millisecond(const PlainDateTime* self); + +uint16_t temporal_rs_PlainDateTime_microsecond(const PlainDateTime* self); + +uint16_t temporal_rs_PlainDateTime_nanosecond(const PlainDateTime* self); + +const Calendar* temporal_rs_PlainDateTime_calendar(const PlainDateTime* self); + +int32_t temporal_rs_PlainDateTime_year(const PlainDateTime* self); + +uint8_t temporal_rs_PlainDateTime_month(const PlainDateTime* self); + +void temporal_rs_PlainDateTime_month_code(const PlainDateTime* self, DiplomatWrite* write); + +uint8_t temporal_rs_PlainDateTime_day(const PlainDateTime* self); + +typedef struct temporal_rs_PlainDateTime_day_of_week_result {union {uint16_t ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_day_of_week_result; +temporal_rs_PlainDateTime_day_of_week_result temporal_rs_PlainDateTime_day_of_week(const PlainDateTime* self); + +uint16_t temporal_rs_PlainDateTime_day_of_year(const PlainDateTime* self); + +typedef struct temporal_rs_PlainDateTime_week_of_year_result {union {uint8_t ok; }; bool is_ok;} temporal_rs_PlainDateTime_week_of_year_result; +temporal_rs_PlainDateTime_week_of_year_result temporal_rs_PlainDateTime_week_of_year(const PlainDateTime* self); + +typedef struct temporal_rs_PlainDateTime_year_of_week_result {union {int32_t ok; }; bool is_ok;} temporal_rs_PlainDateTime_year_of_week_result; +temporal_rs_PlainDateTime_year_of_week_result temporal_rs_PlainDateTime_year_of_week(const PlainDateTime* self); + +typedef struct temporal_rs_PlainDateTime_days_in_week_result {union {uint16_t ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_days_in_week_result; +temporal_rs_PlainDateTime_days_in_week_result temporal_rs_PlainDateTime_days_in_week(const PlainDateTime* self); + +uint16_t temporal_rs_PlainDateTime_days_in_month(const PlainDateTime* self); + +uint16_t temporal_rs_PlainDateTime_days_in_year(const PlainDateTime* self); + +uint16_t temporal_rs_PlainDateTime_months_in_year(const PlainDateTime* self); + +bool temporal_rs_PlainDateTime_in_leap_year(const PlainDateTime* self); + +void temporal_rs_PlainDateTime_era(const PlainDateTime* self, DiplomatWrite* write); + +typedef struct temporal_rs_PlainDateTime_era_year_result {union {int32_t ok; }; bool is_ok;} temporal_rs_PlainDateTime_era_year_result; +temporal_rs_PlainDateTime_era_year_result temporal_rs_PlainDateTime_era_year(const PlainDateTime* self); + +typedef struct temporal_rs_PlainDateTime_add_result {union {PlainDateTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_add_result; +temporal_rs_PlainDateTime_add_result temporal_rs_PlainDateTime_add(const PlainDateTime* self, const Duration* duration, ArithmeticOverflow_option overflow); + +typedef struct temporal_rs_PlainDateTime_subtract_result {union {PlainDateTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_subtract_result; +temporal_rs_PlainDateTime_subtract_result temporal_rs_PlainDateTime_subtract(const PlainDateTime* self, const Duration* duration, ArithmeticOverflow_option overflow); + +typedef struct temporal_rs_PlainDateTime_until_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_until_result; +temporal_rs_PlainDateTime_until_result temporal_rs_PlainDateTime_until(const PlainDateTime* self, const PlainDateTime* other, DifferenceSettings settings); + +typedef struct temporal_rs_PlainDateTime_since_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_since_result; +temporal_rs_PlainDateTime_since_result temporal_rs_PlainDateTime_since(const PlainDateTime* self, const PlainDateTime* other, DifferenceSettings settings); + +bool temporal_rs_PlainDateTime_equals(const PlainDateTime* self, const PlainDateTime* other); + +int8_t temporal_rs_PlainDateTime_compare(const PlainDateTime* one, const PlainDateTime* two); + +typedef struct temporal_rs_PlainDateTime_round_result {union {PlainDateTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_round_result; +temporal_rs_PlainDateTime_round_result temporal_rs_PlainDateTime_round(const PlainDateTime* self, RoundingOptions options); + +typedef struct temporal_rs_PlainDateTime_to_plain_date_result {union {PlainDate* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_to_plain_date_result; +temporal_rs_PlainDateTime_to_plain_date_result temporal_rs_PlainDateTime_to_plain_date(const PlainDateTime* self); + +typedef struct temporal_rs_PlainDateTime_to_plain_time_result {union {PlainTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_to_plain_time_result; +temporal_rs_PlainDateTime_to_plain_time_result temporal_rs_PlainDateTime_to_plain_time(const PlainDateTime* self); + +typedef struct temporal_rs_PlainDateTime_to_ixdtf_string_result {union { TemporalError err;}; bool is_ok;} temporal_rs_PlainDateTime_to_ixdtf_string_result; +temporal_rs_PlainDateTime_to_ixdtf_string_result temporal_rs_PlainDateTime_to_ixdtf_string(const PlainDateTime* self, ToStringRoundingOptions options, DisplayCalendar display_calendar, DiplomatWrite* write); + +void temporal_rs_PlainDateTime_destroy(PlainDateTime* self); + + + + + +#endif // PlainDateTime_H diff --git a/temporal_capi/bindings/c/PlainMonthDay.d.h b/temporal_capi/bindings/c/PlainMonthDay.d.h new file mode 100644 index 000000000..12d40c36d --- /dev/null +++ b/temporal_capi/bindings/c/PlainMonthDay.d.h @@ -0,0 +1,19 @@ +#ifndef PlainMonthDay_D_H +#define PlainMonthDay_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct PlainMonthDay PlainMonthDay; + + + + +#endif // PlainMonthDay_D_H diff --git a/temporal_capi/bindings/c/PlainMonthDay.h b/temporal_capi/bindings/c/PlainMonthDay.h new file mode 100644 index 000000000..7a10011e4 --- /dev/null +++ b/temporal_capi/bindings/c/PlainMonthDay.h @@ -0,0 +1,58 @@ +#ifndef PlainMonthDay_H +#define PlainMonthDay_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ArithmeticOverflow.d.h" +#include "Calendar.d.h" +#include "PartialDate.d.h" +#include "PlainDate.d.h" +#include "TemporalError.d.h" + +#include "PlainMonthDay.d.h" + + + + + + +typedef struct temporal_rs_PlainMonthDay_create_with_overflow_result {union {PlainMonthDay* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainMonthDay_create_with_overflow_result; +temporal_rs_PlainMonthDay_create_with_overflow_result temporal_rs_PlainMonthDay_create_with_overflow(uint8_t month, uint8_t day, const Calendar* calendar, ArithmeticOverflow overflow, OptionI32 ref_year); + +typedef struct temporal_rs_PlainMonthDay_with_result {union {PlainMonthDay* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainMonthDay_with_result; +temporal_rs_PlainMonthDay_with_result temporal_rs_PlainMonthDay_with(const PlainMonthDay* self, PartialDate partial, ArithmeticOverflow overflow); + +bool temporal_rs_PlainMonthDay_equals(const PlainMonthDay* self, const PlainMonthDay* other); + +int8_t temporal_rs_PlainMonthDay_compare(const PlainMonthDay* one, const PlainMonthDay* two); + +typedef struct temporal_rs_PlainMonthDay_from_utf8_result {union {PlainMonthDay* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainMonthDay_from_utf8_result; +temporal_rs_PlainMonthDay_from_utf8_result temporal_rs_PlainMonthDay_from_utf8(DiplomatStringView s); + +typedef struct temporal_rs_PlainMonthDay_from_utf16_result {union {PlainMonthDay* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainMonthDay_from_utf16_result; +temporal_rs_PlainMonthDay_from_utf16_result temporal_rs_PlainMonthDay_from_utf16(DiplomatString16View s); + +int32_t temporal_rs_PlainMonthDay_iso_year(const PlainMonthDay* self); + +uint8_t temporal_rs_PlainMonthDay_iso_month(const PlainMonthDay* self); + +uint8_t temporal_rs_PlainMonthDay_iso_day(const PlainMonthDay* self); + +const Calendar* temporal_rs_PlainMonthDay_calendar(const PlainMonthDay* self); + +void temporal_rs_PlainMonthDay_month_code(const PlainMonthDay* self, DiplomatWrite* write); + +typedef struct temporal_rs_PlainMonthDay_to_plain_date_result {union {PlainDate* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainMonthDay_to_plain_date_result; +temporal_rs_PlainMonthDay_to_plain_date_result temporal_rs_PlainMonthDay_to_plain_date(const PlainMonthDay* self, PartialDate_option year); + +void temporal_rs_PlainMonthDay_destroy(PlainMonthDay* self); + + + + + +#endif // PlainMonthDay_H diff --git a/temporal_capi/bindings/c/PlainTime.d.h b/temporal_capi/bindings/c/PlainTime.d.h new file mode 100644 index 000000000..0d3ca8e32 --- /dev/null +++ b/temporal_capi/bindings/c/PlainTime.d.h @@ -0,0 +1,19 @@ +#ifndef PlainTime_D_H +#define PlainTime_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct PlainTime PlainTime; + + + + +#endif // PlainTime_D_H diff --git a/temporal_capi/bindings/c/PlainTime.h b/temporal_capi/bindings/c/PlainTime.h new file mode 100644 index 000000000..f432361d7 --- /dev/null +++ b/temporal_capi/bindings/c/PlainTime.h @@ -0,0 +1,91 @@ +#ifndef PlainTime_H +#define PlainTime_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ArithmeticOverflow.d.h" +#include "DifferenceSettings.d.h" +#include "Duration.d.h" +#include "PartialTime.d.h" +#include "RoundingMode.d.h" +#include "TemporalError.d.h" +#include "TimeDuration.d.h" +#include "ToStringRoundingOptions.d.h" +#include "Unit.d.h" + +#include "PlainTime.d.h" + + + + + + +typedef struct temporal_rs_PlainTime_create_result {union {PlainTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainTime_create_result; +temporal_rs_PlainTime_create_result temporal_rs_PlainTime_create(uint8_t hour, uint8_t minute, uint8_t second, uint16_t millisecond, uint16_t microsecond, uint16_t nanosecond); + +typedef struct temporal_rs_PlainTime_try_create_result {union {PlainTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainTime_try_create_result; +temporal_rs_PlainTime_try_create_result temporal_rs_PlainTime_try_create(uint8_t hour, uint8_t minute, uint8_t second, uint16_t millisecond, uint16_t microsecond, uint16_t nanosecond); + +typedef struct temporal_rs_PlainTime_from_partial_result {union {PlainTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainTime_from_partial_result; +temporal_rs_PlainTime_from_partial_result temporal_rs_PlainTime_from_partial(PartialTime partial, ArithmeticOverflow_option overflow); + +typedef struct temporal_rs_PlainTime_with_result {union {PlainTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainTime_with_result; +temporal_rs_PlainTime_with_result temporal_rs_PlainTime_with(const PlainTime* self, PartialTime partial, ArithmeticOverflow_option overflow); + +typedef struct temporal_rs_PlainTime_from_utf8_result {union {PlainTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainTime_from_utf8_result; +temporal_rs_PlainTime_from_utf8_result temporal_rs_PlainTime_from_utf8(DiplomatStringView s); + +typedef struct temporal_rs_PlainTime_from_utf16_result {union {PlainTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainTime_from_utf16_result; +temporal_rs_PlainTime_from_utf16_result temporal_rs_PlainTime_from_utf16(DiplomatString16View s); + +uint8_t temporal_rs_PlainTime_hour(const PlainTime* self); + +uint8_t temporal_rs_PlainTime_minute(const PlainTime* self); + +uint8_t temporal_rs_PlainTime_second(const PlainTime* self); + +uint16_t temporal_rs_PlainTime_millisecond(const PlainTime* self); + +uint16_t temporal_rs_PlainTime_microsecond(const PlainTime* self); + +uint16_t temporal_rs_PlainTime_nanosecond(const PlainTime* self); + +typedef struct temporal_rs_PlainTime_add_result {union {PlainTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainTime_add_result; +temporal_rs_PlainTime_add_result temporal_rs_PlainTime_add(const PlainTime* self, const Duration* duration); + +typedef struct temporal_rs_PlainTime_subtract_result {union {PlainTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainTime_subtract_result; +temporal_rs_PlainTime_subtract_result temporal_rs_PlainTime_subtract(const PlainTime* self, const Duration* duration); + +typedef struct temporal_rs_PlainTime_add_time_duration_result {union {PlainTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainTime_add_time_duration_result; +temporal_rs_PlainTime_add_time_duration_result temporal_rs_PlainTime_add_time_duration(const PlainTime* self, const TimeDuration* duration); + +typedef struct temporal_rs_PlainTime_subtract_time_duration_result {union {PlainTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainTime_subtract_time_duration_result; +temporal_rs_PlainTime_subtract_time_duration_result temporal_rs_PlainTime_subtract_time_duration(const PlainTime* self, const TimeDuration* duration); + +typedef struct temporal_rs_PlainTime_until_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainTime_until_result; +temporal_rs_PlainTime_until_result temporal_rs_PlainTime_until(const PlainTime* self, const PlainTime* other, DifferenceSettings settings); + +typedef struct temporal_rs_PlainTime_since_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainTime_since_result; +temporal_rs_PlainTime_since_result temporal_rs_PlainTime_since(const PlainTime* self, const PlainTime* other, DifferenceSettings settings); + +bool temporal_rs_PlainTime_equals(const PlainTime* self, const PlainTime* other); + +int8_t temporal_rs_PlainTime_compare(const PlainTime* one, const PlainTime* two); + +typedef struct temporal_rs_PlainTime_round_result {union {PlainTime* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainTime_round_result; +temporal_rs_PlainTime_round_result temporal_rs_PlainTime_round(const PlainTime* self, Unit smallest_unit, OptionF64 rounding_increment, RoundingMode_option rounding_mode); + +typedef struct temporal_rs_PlainTime_to_ixdtf_string_result {union { TemporalError err;}; bool is_ok;} temporal_rs_PlainTime_to_ixdtf_string_result; +temporal_rs_PlainTime_to_ixdtf_string_result temporal_rs_PlainTime_to_ixdtf_string(const PlainTime* self, ToStringRoundingOptions options, DiplomatWrite* write); + +void temporal_rs_PlainTime_destroy(PlainTime* self); + + + + + +#endif // PlainTime_H diff --git a/temporal_capi/bindings/c/PlainYearMonth.d.h b/temporal_capi/bindings/c/PlainYearMonth.d.h new file mode 100644 index 000000000..beff08754 --- /dev/null +++ b/temporal_capi/bindings/c/PlainYearMonth.d.h @@ -0,0 +1,19 @@ +#ifndef PlainYearMonth_D_H +#define PlainYearMonth_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct PlainYearMonth PlainYearMonth; + + + + +#endif // PlainYearMonth_D_H diff --git a/temporal_capi/bindings/c/PlainYearMonth.h b/temporal_capi/bindings/c/PlainYearMonth.h new file mode 100644 index 000000000..945a9f8dd --- /dev/null +++ b/temporal_capi/bindings/c/PlainYearMonth.h @@ -0,0 +1,89 @@ +#ifndef PlainYearMonth_H +#define PlainYearMonth_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ArithmeticOverflow.d.h" +#include "Calendar.d.h" +#include "DifferenceSettings.d.h" +#include "Duration.d.h" +#include "PartialDate.d.h" +#include "PlainDate.d.h" +#include "TemporalError.d.h" + +#include "PlainYearMonth.d.h" + + + + + + +typedef struct temporal_rs_PlainYearMonth_create_with_overflow_result {union {PlainYearMonth* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainYearMonth_create_with_overflow_result; +temporal_rs_PlainYearMonth_create_with_overflow_result temporal_rs_PlainYearMonth_create_with_overflow(int32_t year, uint8_t month, OptionU8 reference_day, const Calendar* calendar, ArithmeticOverflow overflow); + +typedef struct temporal_rs_PlainYearMonth_with_result {union {PlainYearMonth* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainYearMonth_with_result; +temporal_rs_PlainYearMonth_with_result temporal_rs_PlainYearMonth_with(const PlainYearMonth* self, PartialDate partial, ArithmeticOverflow_option overflow); + +typedef struct temporal_rs_PlainYearMonth_from_utf8_result {union {PlainYearMonth* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainYearMonth_from_utf8_result; +temporal_rs_PlainYearMonth_from_utf8_result temporal_rs_PlainYearMonth_from_utf8(DiplomatStringView s); + +typedef struct temporal_rs_PlainYearMonth_from_utf16_result {union {PlainYearMonth* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainYearMonth_from_utf16_result; +temporal_rs_PlainYearMonth_from_utf16_result temporal_rs_PlainYearMonth_from_utf16(DiplomatString16View s); + +int32_t temporal_rs_PlainYearMonth_iso_year(const PlainYearMonth* self); + +void temporal_rs_PlainYearMonth_padded_iso_year_string(const PlainYearMonth* self, DiplomatWrite* write); + +uint8_t temporal_rs_PlainYearMonth_iso_month(const PlainYearMonth* self); + +int32_t temporal_rs_PlainYearMonth_year(const PlainYearMonth* self); + +uint8_t temporal_rs_PlainYearMonth_month(const PlainYearMonth* self); + +void temporal_rs_PlainYearMonth_month_code(const PlainYearMonth* self, DiplomatWrite* write); + +bool temporal_rs_PlainYearMonth_in_leap_year(const PlainYearMonth* self); + +uint16_t temporal_rs_PlainYearMonth_days_in_month(const PlainYearMonth* self); + +uint16_t temporal_rs_PlainYearMonth_days_in_year(const PlainYearMonth* self); + +uint16_t temporal_rs_PlainYearMonth_months_in_year(const PlainYearMonth* self); + +void temporal_rs_PlainYearMonth_era(const PlainYearMonth* self, DiplomatWrite* write); + +typedef struct temporal_rs_PlainYearMonth_era_year_result {union {int32_t ok; }; bool is_ok;} temporal_rs_PlainYearMonth_era_year_result; +temporal_rs_PlainYearMonth_era_year_result temporal_rs_PlainYearMonth_era_year(const PlainYearMonth* self); + +const Calendar* temporal_rs_PlainYearMonth_calendar(const PlainYearMonth* self); + +typedef struct temporal_rs_PlainYearMonth_add_result {union {PlainYearMonth* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainYearMonth_add_result; +temporal_rs_PlainYearMonth_add_result temporal_rs_PlainYearMonth_add(const PlainYearMonth* self, const Duration* duration, ArithmeticOverflow overflow); + +typedef struct temporal_rs_PlainYearMonth_subtract_result {union {PlainYearMonth* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainYearMonth_subtract_result; +temporal_rs_PlainYearMonth_subtract_result temporal_rs_PlainYearMonth_subtract(const PlainYearMonth* self, const Duration* duration, ArithmeticOverflow overflow); + +typedef struct temporal_rs_PlainYearMonth_until_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainYearMonth_until_result; +temporal_rs_PlainYearMonth_until_result temporal_rs_PlainYearMonth_until(const PlainYearMonth* self, const PlainYearMonth* other, DifferenceSettings settings); + +typedef struct temporal_rs_PlainYearMonth_since_result {union {Duration* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainYearMonth_since_result; +temporal_rs_PlainYearMonth_since_result temporal_rs_PlainYearMonth_since(const PlainYearMonth* self, const PlainYearMonth* other, DifferenceSettings settings); + +bool temporal_rs_PlainYearMonth_equals(const PlainYearMonth* self, const PlainYearMonth* other); + +int8_t temporal_rs_PlainYearMonth_compare(const PlainYearMonth* one, const PlainYearMonth* two); + +typedef struct temporal_rs_PlainYearMonth_to_plain_date_result {union {PlainDate* ok; TemporalError err;}; bool is_ok;} temporal_rs_PlainYearMonth_to_plain_date_result; +temporal_rs_PlainYearMonth_to_plain_date_result temporal_rs_PlainYearMonth_to_plain_date(const PlainYearMonth* self, PartialDate_option day); + +void temporal_rs_PlainYearMonth_destroy(PlainYearMonth* self); + + + + + +#endif // PlainYearMonth_H diff --git a/temporal_capi/bindings/c/Precision.d.h b/temporal_capi/bindings/c/Precision.d.h new file mode 100644 index 000000000..858901bc4 --- /dev/null +++ b/temporal_capi/bindings/c/Precision.d.h @@ -0,0 +1,23 @@ +#ifndef Precision_D_H +#define Precision_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct Precision { + bool is_minute; + OptionU8 precision; +} Precision; + +typedef struct Precision_option {union { Precision ok; }; bool is_ok; } Precision_option; + + + +#endif // Precision_D_H diff --git a/temporal_capi/bindings/c/Precision.h b/temporal_capi/bindings/c/Precision.h new file mode 100644 index 000000000..b184fe141 --- /dev/null +++ b/temporal_capi/bindings/c/Precision.h @@ -0,0 +1,22 @@ +#ifndef Precision_H +#define Precision_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "Precision.d.h" + + + + + + + + + + +#endif // Precision_H diff --git a/temporal_capi/bindings/c/RoundingMode.d.h b/temporal_capi/bindings/c/RoundingMode.d.h new file mode 100644 index 000000000..b6bdd3aa0 --- /dev/null +++ b/temporal_capi/bindings/c/RoundingMode.d.h @@ -0,0 +1,30 @@ +#ifndef RoundingMode_D_H +#define RoundingMode_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef enum RoundingMode { + RoundingMode_Ceil = 0, + RoundingMode_Floor = 1, + RoundingMode_Expand = 2, + RoundingMode_Trunc = 3, + RoundingMode_HalfCeil = 4, + RoundingMode_HalfFloor = 5, + RoundingMode_HalfExpand = 6, + RoundingMode_HalfTrunc = 7, + RoundingMode_HalfEven = 8, +} RoundingMode; + +typedef struct RoundingMode_option {union { RoundingMode ok; }; bool is_ok; } RoundingMode_option; + + + +#endif // RoundingMode_D_H diff --git a/temporal_capi/bindings/c/RoundingMode.h b/temporal_capi/bindings/c/RoundingMode.h new file mode 100644 index 000000000..5c028595f --- /dev/null +++ b/temporal_capi/bindings/c/RoundingMode.h @@ -0,0 +1,22 @@ +#ifndef RoundingMode_H +#define RoundingMode_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "RoundingMode.d.h" + + + + + + + + + + +#endif // RoundingMode_H diff --git a/temporal_capi/bindings/c/RoundingOptions.d.h b/temporal_capi/bindings/c/RoundingOptions.d.h new file mode 100644 index 000000000..37c2bc25a --- /dev/null +++ b/temporal_capi/bindings/c/RoundingOptions.d.h @@ -0,0 +1,27 @@ +#ifndef RoundingOptions_D_H +#define RoundingOptions_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "RoundingMode.d.h" +#include "Unit.d.h" + + + + +typedef struct RoundingOptions { + Unit_option largest_unit; + Unit_option smallest_unit; + RoundingMode_option rounding_mode; + OptionU32 increment; +} RoundingOptions; + +typedef struct RoundingOptions_option {union { RoundingOptions ok; }; bool is_ok; } RoundingOptions_option; + + + +#endif // RoundingOptions_D_H diff --git a/temporal_capi/bindings/c/RoundingOptions.h b/temporal_capi/bindings/c/RoundingOptions.h new file mode 100644 index 000000000..0d0c4f6cb --- /dev/null +++ b/temporal_capi/bindings/c/RoundingOptions.h @@ -0,0 +1,22 @@ +#ifndef RoundingOptions_H +#define RoundingOptions_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "RoundingOptions.d.h" + + + + + + + + + + +#endif // RoundingOptions_H diff --git a/temporal_capi/bindings/c/Sign.d.h b/temporal_capi/bindings/c/Sign.d.h new file mode 100644 index 000000000..787837d28 --- /dev/null +++ b/temporal_capi/bindings/c/Sign.d.h @@ -0,0 +1,24 @@ +#ifndef Sign_D_H +#define Sign_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef enum Sign { + Sign_Positive = 1, + Sign_Zero = 0, + Sign_Negative = -1, +} Sign; + +typedef struct Sign_option {union { Sign ok; }; bool is_ok; } Sign_option; + + + +#endif // Sign_D_H diff --git a/temporal_capi/bindings/c/Sign.h b/temporal_capi/bindings/c/Sign.h new file mode 100644 index 000000000..10f470c34 --- /dev/null +++ b/temporal_capi/bindings/c/Sign.h @@ -0,0 +1,22 @@ +#ifndef Sign_H +#define Sign_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "Sign.d.h" + + + + + + + + + + +#endif // Sign_H diff --git a/temporal_capi/bindings/c/TemporalError.d.h b/temporal_capi/bindings/c/TemporalError.d.h new file mode 100644 index 000000000..9b2953996 --- /dev/null +++ b/temporal_capi/bindings/c/TemporalError.d.h @@ -0,0 +1,23 @@ +#ifndef TemporalError_D_H +#define TemporalError_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ErrorKind.d.h" + + + + +typedef struct TemporalError { + ErrorKind kind; +} TemporalError; + +typedef struct TemporalError_option {union { TemporalError ok; }; bool is_ok; } TemporalError_option; + + + +#endif // TemporalError_D_H diff --git a/temporal_capi/bindings/c/TemporalError.h b/temporal_capi/bindings/c/TemporalError.h new file mode 100644 index 000000000..5386db883 --- /dev/null +++ b/temporal_capi/bindings/c/TemporalError.h @@ -0,0 +1,22 @@ +#ifndef TemporalError_H +#define TemporalError_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "TemporalError.d.h" + + + + + + + + + + +#endif // TemporalError_H diff --git a/temporal_capi/bindings/c/TimeDuration.d.h b/temporal_capi/bindings/c/TimeDuration.d.h new file mode 100644 index 000000000..f7211713e --- /dev/null +++ b/temporal_capi/bindings/c/TimeDuration.d.h @@ -0,0 +1,19 @@ +#ifndef TimeDuration_D_H +#define TimeDuration_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct TimeDuration TimeDuration; + + + + +#endif // TimeDuration_D_H diff --git a/temporal_capi/bindings/c/TimeDuration.h b/temporal_capi/bindings/c/TimeDuration.h new file mode 100644 index 000000000..190546e8a --- /dev/null +++ b/temporal_capi/bindings/c/TimeDuration.h @@ -0,0 +1,37 @@ +#ifndef TimeDuration_H +#define TimeDuration_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "Sign.d.h" +#include "TemporalError.d.h" + +#include "TimeDuration.d.h" + + + + + + +typedef struct temporal_rs_TimeDuration_new_result {union {TimeDuration* ok; TemporalError err;}; bool is_ok;} temporal_rs_TimeDuration_new_result; +temporal_rs_TimeDuration_new_result temporal_rs_TimeDuration_new(int64_t hours, int64_t minutes, int64_t seconds, int64_t milliseconds, double microseconds, double nanoseconds); + +TimeDuration* temporal_rs_TimeDuration_abs(const TimeDuration* self); + +TimeDuration* temporal_rs_TimeDuration_negated(const TimeDuration* self); + +bool temporal_rs_TimeDuration_is_within_range(const TimeDuration* self); + +Sign temporal_rs_TimeDuration_sign(const TimeDuration* self); + +void temporal_rs_TimeDuration_destroy(TimeDuration* self); + + + + + +#endif // TimeDuration_H diff --git a/temporal_capi/bindings/c/TimeZone.d.h b/temporal_capi/bindings/c/TimeZone.d.h new file mode 100644 index 000000000..021382db7 --- /dev/null +++ b/temporal_capi/bindings/c/TimeZone.d.h @@ -0,0 +1,19 @@ +#ifndef TimeZone_D_H +#define TimeZone_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct TimeZone TimeZone; + + + + +#endif // TimeZone_D_H diff --git a/temporal_capi/bindings/c/TimeZone.h b/temporal_capi/bindings/c/TimeZone.h new file mode 100644 index 000000000..a2c286a2f --- /dev/null +++ b/temporal_capi/bindings/c/TimeZone.h @@ -0,0 +1,31 @@ +#ifndef TimeZone_H +#define TimeZone_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "TemporalError.d.h" + +#include "TimeZone.d.h" + + + + + + +typedef struct temporal_rs_TimeZone_try_from_identifier_str_result {union {TimeZone* ok; TemporalError err;}; bool is_ok;} temporal_rs_TimeZone_try_from_identifier_str_result; +temporal_rs_TimeZone_try_from_identifier_str_result temporal_rs_TimeZone_try_from_identifier_str(DiplomatStringView ident); + +typedef struct temporal_rs_TimeZone_try_from_str_result {union {TimeZone* ok; TemporalError err;}; bool is_ok;} temporal_rs_TimeZone_try_from_str_result; +temporal_rs_TimeZone_try_from_str_result temporal_rs_TimeZone_try_from_str(DiplomatStringView ident); + +void temporal_rs_TimeZone_destroy(TimeZone* self); + + + + + +#endif // TimeZone_H diff --git a/temporal_capi/bindings/c/ToStringRoundingOptions.d.h b/temporal_capi/bindings/c/ToStringRoundingOptions.d.h new file mode 100644 index 000000000..7cb507079 --- /dev/null +++ b/temporal_capi/bindings/c/ToStringRoundingOptions.d.h @@ -0,0 +1,27 @@ +#ifndef ToStringRoundingOptions_D_H +#define ToStringRoundingOptions_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "Precision.d.h" +#include "RoundingMode.d.h" +#include "Unit.d.h" + + + + +typedef struct ToStringRoundingOptions { + Precision precision; + Unit_option smallest_unit; + RoundingMode_option rounding_mode; +} ToStringRoundingOptions; + +typedef struct ToStringRoundingOptions_option {union { ToStringRoundingOptions ok; }; bool is_ok; } ToStringRoundingOptions_option; + + + +#endif // ToStringRoundingOptions_D_H diff --git a/temporal_capi/bindings/c/ToStringRoundingOptions.h b/temporal_capi/bindings/c/ToStringRoundingOptions.h new file mode 100644 index 000000000..cc43e6f5e --- /dev/null +++ b/temporal_capi/bindings/c/ToStringRoundingOptions.h @@ -0,0 +1,22 @@ +#ifndef ToStringRoundingOptions_H +#define ToStringRoundingOptions_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "ToStringRoundingOptions.d.h" + + + + + + + + + + +#endif // ToStringRoundingOptions_H diff --git a/temporal_capi/bindings/c/Unit.d.h b/temporal_capi/bindings/c/Unit.d.h new file mode 100644 index 000000000..00d816ee8 --- /dev/null +++ b/temporal_capi/bindings/c/Unit.d.h @@ -0,0 +1,32 @@ +#ifndef Unit_D_H +#define Unit_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef enum Unit { + Unit_Auto = 0, + Unit_Nanosecond = 1, + Unit_Microsecond = 2, + Unit_Millisecond = 3, + Unit_Second = 4, + Unit_Minute = 5, + Unit_Hour = 6, + Unit_Day = 7, + Unit_Week = 8, + Unit_Month = 9, + Unit_Year = 10, +} Unit; + +typedef struct Unit_option {union { Unit ok; }; bool is_ok; } Unit_option; + + + +#endif // Unit_D_H diff --git a/temporal_capi/bindings/c/Unit.h b/temporal_capi/bindings/c/Unit.h new file mode 100644 index 000000000..7ad636122 --- /dev/null +++ b/temporal_capi/bindings/c/Unit.h @@ -0,0 +1,22 @@ +#ifndef Unit_H +#define Unit_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "Unit.d.h" + + + + + + + + + + +#endif // Unit_H diff --git a/temporal_capi/bindings/c/UnsignedRoundingMode.d.h b/temporal_capi/bindings/c/UnsignedRoundingMode.d.h new file mode 100644 index 000000000..c0f18ebb4 --- /dev/null +++ b/temporal_capi/bindings/c/UnsignedRoundingMode.d.h @@ -0,0 +1,26 @@ +#ifndef UnsignedRoundingMode_D_H +#define UnsignedRoundingMode_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef enum UnsignedRoundingMode { + UnsignedRoundingMode_Infinity = 0, + UnsignedRoundingMode_Zero = 1, + UnsignedRoundingMode_HalfInfinity = 2, + UnsignedRoundingMode_HalfZero = 3, + UnsignedRoundingMode_HalfEven = 4, +} UnsignedRoundingMode; + +typedef struct UnsignedRoundingMode_option {union { UnsignedRoundingMode ok; }; bool is_ok; } UnsignedRoundingMode_option; + + + +#endif // UnsignedRoundingMode_D_H diff --git a/temporal_capi/bindings/c/UnsignedRoundingMode.h b/temporal_capi/bindings/c/UnsignedRoundingMode.h new file mode 100644 index 000000000..4e68a3ba3 --- /dev/null +++ b/temporal_capi/bindings/c/UnsignedRoundingMode.h @@ -0,0 +1,22 @@ +#ifndef UnsignedRoundingMode_H +#define UnsignedRoundingMode_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "UnsignedRoundingMode.d.h" + + + + + + + + + + +#endif // UnsignedRoundingMode_H diff --git a/temporal_capi/bindings/c/diplomat_runtime.h b/temporal_capi/bindings/c/diplomat_runtime.h new file mode 100644 index 000000000..e5d6b298d --- /dev/null +++ b/temporal_capi/bindings/c/diplomat_runtime.h @@ -0,0 +1,82 @@ +#ifndef DIPLOMAT_RUNTIME_C_H +#define DIPLOMAT_RUNTIME_C_H + +#include +#include +#include +#include + +// These come from `uchar.h`, which is not available on all platforms. +// Redefining them in C is no problem, however in >C++11 they are fundamental +// types, which don't like being redefined. +#if !(__cplusplus >= 201100) +// https://en.cppreference.com/w/c/string/multibyte/char16_t +typedef uint_least16_t char16_t; +// https://en.cppreference.com/w/c/string/multibyte/char32_t +typedef uint_least32_t char32_t; +#endif + +static_assert(sizeof(char) == sizeof(uint8_t), "your architecture's `char` is not 8 bits"); +static_assert(sizeof(char16_t) == sizeof(uint16_t), "your architecture's `char16_t` is not 16 bits"); +static_assert(sizeof(char32_t) == sizeof(uint32_t), "your architecture's `char32_t` is not 32 bits"); + +typedef struct DiplomatWrite { + void* context; + char* buf; + size_t len; + size_t cap; + bool grow_failed; + void (*flush)(struct DiplomatWrite*); + bool (*grow)(struct DiplomatWrite*, size_t); +} DiplomatWrite; + +bool diplomat_is_str(const char* buf, size_t len); + +#define MAKE_SLICES(name, c_ty) \ + typedef struct Diplomat##name##View { \ + const c_ty* data; \ + size_t len; \ + } Diplomat##name##View; \ + typedef struct Diplomat##name##ViewMut { \ + c_ty* data; \ + size_t len; \ + } Diplomat##name##ViewMut; \ + typedef struct Diplomat##name##Array { \ + const c_ty* data; \ + size_t len; \ + } Diplomat##name##Array; + +#define MAKE_SLICES_AND_OPTIONS(name, c_ty) \ + MAKE_SLICES(name, c_ty) \ + typedef struct Option##name {union { c_ty ok; }; bool is_ok; } Option##name; \ + typedef struct Option##name##View {union { Diplomat##name##View ok; }; bool is_ok; } Option##name##View; \ + typedef struct Option##name##ViewMut {union { Diplomat##name##ViewMut ok; }; bool is_ok; } Option##name##ViewMut; \ + typedef struct Option##name##Array {union { Diplomat##name##Array ok; }; bool is_ok; } Option##name##Array; \ + +MAKE_SLICES_AND_OPTIONS(I8, int8_t) +MAKE_SLICES_AND_OPTIONS(U8, uint8_t) +MAKE_SLICES_AND_OPTIONS(I16, int16_t) +MAKE_SLICES_AND_OPTIONS(U16, uint16_t) +MAKE_SLICES_AND_OPTIONS(I32, int32_t) +MAKE_SLICES_AND_OPTIONS(U32, uint32_t) +MAKE_SLICES_AND_OPTIONS(I64, int64_t) +MAKE_SLICES_AND_OPTIONS(U64, uint64_t) +MAKE_SLICES_AND_OPTIONS(Isize, intptr_t) +MAKE_SLICES_AND_OPTIONS(Usize, size_t) +MAKE_SLICES_AND_OPTIONS(F32, float) +MAKE_SLICES_AND_OPTIONS(F64, double) +MAKE_SLICES_AND_OPTIONS(Bool, bool) +MAKE_SLICES_AND_OPTIONS(Char, char32_t) +MAKE_SLICES_AND_OPTIONS(String, char) +MAKE_SLICES_AND_OPTIONS(String16, char16_t) +MAKE_SLICES_AND_OPTIONS(Strings, DiplomatStringView) +MAKE_SLICES_AND_OPTIONS(Strings16, DiplomatString16View) + +DiplomatWrite diplomat_simple_write(char* buf, size_t buf_size); + +DiplomatWrite* diplomat_buffer_write_create(size_t cap); +char* diplomat_buffer_write_get_bytes(DiplomatWrite* t); +size_t diplomat_buffer_write_len(DiplomatWrite* t); +void diplomat_buffer_write_destroy(DiplomatWrite* t); + +#endif diff --git a/temporal_capi/tests/c/Makefile b/temporal_capi/tests/c/Makefile new file mode 100644 index 000000000..91a6fbef0 --- /dev/null +++ b/temporal_capi/tests/c/Makefile @@ -0,0 +1,25 @@ +.DEFAULT_GOAL := test +.PHONY: build test +FORCE: + +HEADERS := ../../bindings/c/ +ALL_HEADERS := $(wildcard ${HEADERS}/**/*.h) + +C?=gcc + +TEST_FILES := $(wildcard *.c) +OUT_FILES = $(patsubst %.c,%.out,$(TEST_FILES)) + +$(ALL_HEADERS): + +../../../target/debug/libtemporal_capi.a: FORCE + cargo rustc -p temporal_capi --crate-type staticlib + +%.out: %.c ../../../target/debug/libtemporal_capi.a $(ALL_HEADERS) + $(C) -L ../../../target/debug/ -I ${HEADERS} $< -ltemporal_capi -lm -o $@ + ./$@ + +test: $(OUT_FILES) + +clean: + rm $(OUT_FILES) diff --git a/temporal_capi/tests/c/simple.c b/temporal_capi/tests/c/simple.c new file mode 100644 index 000000000..b298e5ec2 --- /dev/null +++ b/temporal_capi/tests/c/simple.c @@ -0,0 +1,38 @@ +#include "ArithmeticOverflow.d.h" +#include "Calendar.h" +#include "DisplayCalendar.d.h" +#include "PlainDate.h" +#include "diplomat_runtime.h" +#include + +int main() { + Calendar *cal = temporal_rs_Calendar_create(AnyCalendarKind_Gregorian); + + temporal_rs_PlainDate_create_with_overflow_result result = + temporal_rs_PlainDate_create_with_overflow(2025, 1, 33, cal, ArithmeticOverflow_Constrain); + + if (!result.is_ok) { + fprintf(stderr, "failed to create a PlainDate\n"); + temporal_rs_Calendar_destroy(cal); + return 1; + } + + PlainDate *date = result.ok; + char formatted[40]; + DiplomatWrite write = diplomat_simple_write(formatted, 40); + + temporal_rs_PlainDate_to_ixdtf_string(date, DisplayCalendar_Always, &write); + if (write.grow_failed) { + fprintf(stderr, "format overflowed the string\n"); + temporal_rs_Calendar_destroy(cal); + temporal_rs_PlainDate_destroy(date); + return 1; + } + + printf("%s\n", formatted); + + temporal_rs_Calendar_destroy(cal); + temporal_rs_PlainDate_destroy(date); + + return 0; +} diff --git a/temporal_capi/cpp_tests/Makefile b/temporal_capi/tests/cpp/Makefile similarity index 56% rename from temporal_capi/cpp_tests/Makefile rename to temporal_capi/tests/cpp/Makefile index abaed3e02..2e17a4845 100644 --- a/temporal_capi/cpp_tests/Makefile +++ b/temporal_capi/tests/cpp/Makefile @@ -2,7 +2,7 @@ .PHONY: build test FORCE: -HEADERS := ../bindings/cpp/ +HEADERS := ../../bindings/cpp/ ALL_HEADERS := $(wildcard ${HEADERS}/**/*.hpp) CXX?=g++ @@ -12,11 +12,11 @@ OUT_FILES = $(patsubst %.cpp,%.out,$(TEST_FILES)) $(ALL_HEADERS): -../../target/debug/libtemporal_capi.a: FORCE +../../../target/debug/libtemporal_capi.a: FORCE cargo rustc -p temporal_capi --crate-type staticlib -%.out: %.cpp ../../target/debug/libtemporal_capi.a $(ALL_HEADERS) - $(CXX) -std=c++17 -L ../../target/debug/ -I ${HEADERS} $< -ltemporal_capi -lm -o $@ +%.out: %.cpp ../../../target/debug/libtemporal_capi.a $(ALL_HEADERS) + $(CXX) -std=c++17 -L ../../../target/debug/ -I ${HEADERS} $< -ltemporal_capi -lm -o $@ ./$@ test: $(OUT_FILES) diff --git a/temporal_capi/cpp_tests/simple.cpp b/temporal_capi/tests/cpp/simple.cpp similarity index 100% rename from temporal_capi/cpp_tests/simple.cpp rename to temporal_capi/tests/cpp/simple.cpp