diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ac9b6e4..0453e0c 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -24,8 +24,27 @@ jobs: - name: Regenerate presets.rs working-directory: tools run: uv run python generate-rust.py - - name: Verify presets.rs matches committed output - run: git diff --exit-code src/zmanim/presets.rs + - name: Regenerate interop generated files + working-directory: tools + run: uv run python generate-interop.py + - name: Verify generated outputs match committed files + run: git diff --exit-code src/zmanim/presets.rs interop/src/generated interop/src/zman_preset.rs + + diplomat-interop: + name: Diplomat interop + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - uses: astral-sh/setup-uv@v5 + with: + python-version: "3.14" + - uses: Swatinem/rust-cache@v2 + - name: Regenerate interop files + working-directory: tools + run: uv run python generate-interop.py + - name: Build and test interop crate + run: cargo test -p interop fmt: name: Format @@ -105,6 +124,33 @@ jobs: working-directory: interop-tests/js_interop_tests run: cargo test --test js_interop + typescript-interop: + name: TypeScript interop + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + target: wasm32-unknown-unknown + - uses: astral-sh/setup-uv@v5 + with: + python-version: "3.14" + - uses: Swatinem/rust-cache@v2 + - uses: actions/setup-node@v4 + with: + node-version: "22" + - name: Regenerate interop files + working-directory: tools + run: uv run python generate-interop.py + - name: Install diplomat-tool + run: cargo install diplomat-tool --version 0.15.0 --locked + - name: Test TypeScript package + working-directory: interop/packages/typescript + run: | + npm run generate + npm test + npm run typecheck + java-interop-tests: name: Java Interop Tests runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 9b76059..68c796b 100644 --- a/.gitignore +++ b/.gitignore @@ -42,7 +42,7 @@ dist/ downloads/ eggs/ .eggs/ -lib/ +# lib/ lib64/ parts/ sdist/ diff --git a/Cargo.lock b/Cargo.lock index 447de3f..1f08955 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -357,6 +357,38 @@ dependencies = [ "subtle", ] +[[package]] +name = "diplomat" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7935649d00000f5c5d735448ad3dc07b9738160727017914cf42138b8e8e6611" +dependencies = [ + "diplomat_core", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "diplomat-runtime" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "970ac38ad677632efcee6d517e783958da9bc78ec206d8d5e35b459ffc5e4864" + +[[package]] +name = "diplomat_core" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf41b94101a4bce993febaf0098092b0bb31deaf0ecaf6e0a2562465f61b383" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "smallvec", + "strck", + "syn", +] + [[package]] name = "displaydoc" version = "0.2.6" @@ -622,6 +654,19 @@ dependencies = [ "generic-array", ] +[[package]] +name = "interop" +version = "0.1.0" +dependencies = [ + "diplomat", + "diplomat-runtime", + "icu_calendar", + "jiff", + "jiff-icu", + "kosher-rust", + "num_enum", +] + [[package]] name = "is-terminal" version = "0.4.17" @@ -718,10 +763,12 @@ checksum = "392c70591e8749fe235ddaf513e6f58b26bce3dcc16524cecc8936f75afa161e" dependencies = [ "jiff-static", "jiff-tzdb", + "jiff-tzdb-platform", "log", "portable-atomic", "portable-atomic-util", "serde_core", + "windows-link", ] [[package]] @@ -751,6 +798,15 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c900ef84826f1338a557697dc8fc601df9ca9af4ac137c7fb61d4c6f2dfd3076" +[[package]] +name = "jiff-tzdb-platform" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8" +dependencies = [ + "jiff-tzdb", +] + [[package]] name = "jni" version = "0.22.4" @@ -1369,12 +1425,27 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" +[[package]] +name = "smallvec" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" + [[package]] name = "stable_deref_trait" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" +[[package]] +name = "strck" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42316e70da376f3d113a68d138a60d8a9883c604fe97942721ec2068dab13a9f" +dependencies = [ + "unicode-ident", +] + [[package]] name = "strsim" version = "0.11.1" diff --git a/Cargo.toml b/Cargo.toml index d4898e3..f4f4b9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,7 +63,7 @@ workspace = true [workspace] resolver = "2" -members = ["interop-tests/java_interop_tests", "interop-tests/js_interop_tests"] +members = ["interop","interop-tests/java_interop_tests", "interop-tests/js_interop_tests"] [workspace.lints.rust] missing_docs = "warn" diff --git a/interop/.gitignore b/interop/.gitignore new file mode 100644 index 0000000..adb18d6 --- /dev/null +++ b/interop/.gitignore @@ -0,0 +1 @@ +/bindings/ diff --git a/interop/Cargo.toml b/interop/Cargo.toml new file mode 100644 index 0000000..f572881 --- /dev/null +++ b/interop/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "interop" +version = "0.1.0" +edition = "2024" +publish = false + +[lib] +crate-type = ["cdylib", "staticlib", "rlib"] + +[dependencies] +diplomat = "0.15.0" +diplomat-runtime = "0.15.1" +icu_calendar = { version = "2.2.0", default-features = false } +jiff = { version = "0.2.0", features = ["std", "alloc", "tzdb-bundle-always"] } +jiff-icu = { version = "0.2.0", default-features = false } +kosher-rust = { path = "..", features = ["alloc"] } +num_enum = { version = "0.7.0", default-features = false } + +[build-dependencies] + +[dev-dependencies] +kosher-rust = { path = "..", features = ["alloc"] } +jiff = { version = "0.2.0", features = ["std", "alloc", "tzdb-bundle-always"] } + +[lints] +workspace = true + +[[test]] +name = "adapter_tests" +path = "tests/adapter_tests.rs" diff --git a/interop/README.md b/interop/README.md new file mode 100644 index 0000000..74b4202 --- /dev/null +++ b/interop/README.md @@ -0,0 +1,34 @@ +# kosher-rust Diplomat interop + +Multi-language FFI bridge for [`kosher-rust`](../README.md), built with [Diplomat](https://rust-diplomat.github.io/diplomat/). + +## Regeneration + +Preset IDs and dispatch tables are generated from the same DSL as [`src/zmanim/presets.rs`](../src/zmanim/presets.rs): + +```bash +cd tools +uv run python generate-interop.py +``` + +This runs automatically from [`build.rs`](build.rs) on every `cargo build -p interop`. + +## TypeScript / JavaScript package + +Bindings live in [`packages/typescript`](packages/typescript/). Regenerate and test: + +```bash +cd interop/packages/typescript +npm install +npm run generate # diplomat-tool js → lib/ +npm run build:wasm # cargo build -p interop --target wasm32-unknown-unknown +npm test +``` + +WASM path is configured in [`packages/typescript/diplomat.config.mjs`](packages/typescript/diplomat.config.mjs) (relative to the repo `target/` directory). + +## Dart package + +See [`packages/dart`](packages/dart/) — run `dart pub get && dart test` after building the native library via the package hook. + + diff --git a/interop/packages/dart/.gitignore b/interop/packages/dart/.gitignore new file mode 100644 index 0000000..bf71f4d --- /dev/null +++ b/interop/packages/dart/.gitignore @@ -0,0 +1,7 @@ +# https://dart.dev/tools/private-files +# Created by `dart pub` +.dart_tool/ + +# Avoid committing pubspec.lock for library packages; see +# https://dart.dev/tools/pub/private-files#pubspec-lock. +pubspec.lock diff --git a/interop/packages/dart/analysis_options.yaml b/interop/packages/dart/analysis_options.yaml new file mode 100644 index 0000000..169d660 --- /dev/null +++ b/interop/packages/dart/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/tools/analysis diff --git a/interop/packages/dart/hook/build.dart b/interop/packages/dart/hook/build.dart new file mode 100644 index 0000000..c559bc0 --- /dev/null +++ b/interop/packages/dart/hook/build.dart @@ -0,0 +1,135 @@ +import 'dart:io'; + +import 'package:code_assets/code_assets.dart'; +import 'package:hooks/hooks.dart'; + +const crateName = 'interop'; + +void main(List args) async { + await build(args, (input, output) async { + if (!input.config.buildCodeAssets) return; + + final codeConfig = input.config.code; + final targetTriple = _targetTriple(codeConfig); + final workspaceRoot = input.packageRoot.resolve('../../..'); + final libraryFileName = codeConfig.targetOS.dylibFileName( + crateName.replaceAll('-', '_'), + ); + final libraryPath = workspaceRoot.resolve( + 'target/$targetTriple/debug/$libraryFileName', + ); + + final cargo = await Process.run( + 'cargo', + ['build', '-p', crateName, '--target', targetTriple], + workingDirectory: workspaceRoot.toFilePath(), + environment: _cargoEnvironment(codeConfig, targetTriple), + ); + + if (cargo.exitCode != 0) { + throw Exception( + 'Failed to build $crateName for $targetTriple:\n' + '${cargo.stderr}\n${cargo.stdout}', + ); + } + + if (!File.fromUri(libraryPath).existsSync()) { + throw Exception( + 'Expected native library at ${libraryPath.toFilePath()} ' + 'after cargo build for $targetTriple.', + ); + } + + output.assets.code.add( + CodeAsset( + package: input.packageName, + name: 'lib.g.dart', + linkMode: DynamicLoadingBundled(), + file: libraryPath, + ), + ); + + output.dependencies.add(workspaceRoot.resolve('interop/Cargo.toml')); + }); +} + +String _targetTriple(CodeConfig config) { + return switch ((config.targetOS, config.targetArchitecture)) { + (OS.android, Architecture.arm64) => 'aarch64-linux-android', + (OS.android, Architecture.arm) => 'armv7-linux-androideabi', + (OS.android, Architecture.x64) => 'x86_64-linux-android', + (OS.iOS, Architecture.arm64) when config.iOS.targetSdk == IOSSdk.iPhoneSimulator => + 'aarch64-apple-ios-sim', + (OS.iOS, Architecture.arm64) => 'aarch64-apple-ios', + (OS.iOS, Architecture.x64) => 'x86_64-apple-ios', + (OS.windows, Architecture.arm64) => 'aarch64-pc-windows-msvc', + (OS.windows, Architecture.x64) => 'x86_64-pc-windows-msvc', + (OS.linux, Architecture.arm64) => 'aarch64-unknown-linux-gnu', + (OS.linux, Architecture.x64) => 'x86_64-unknown-linux-gnu', + (OS.macOS, Architecture.arm64) => 'aarch64-apple-darwin', + (OS.macOS, Architecture.x64) => 'x86_64-apple-darwin', + _ => throw UnsupportedError( + 'Unsupported target: ${config.targetOS} on ${config.targetArchitecture}', + ), + }; +} + +Map _cargoEnvironment( + CodeConfig config, + String targetTriple, +) { + if (config.targetOS != OS.android) { + return const {}; + } + + final cCompiler = config.cCompiler; + if (cCompiler == null) { + throw UnsupportedError( + 'CCompilerConfig was not provided but is required for $targetTriple', + ); + } + + final compilerPath = cCompiler.compiler.toFilePath(); + final compilerBinariesDir = Directory(compilerPath).parent.path; + final targetTripleEnvVar = targetTriple.replaceAll('-', '_'); + final ndkTargetTriple = switch (targetTriple) { + 'armv7-linux-androideabi' => 'armv7a-linux-androideabi', + _ => targetTriple, + }; + final ndkSysrootTargetTriple = switch (targetTriple) { + 'armv7-linux-androideabi' => 'arm-linux-androideabi', + _ => targetTriple, + }; + + String binaryPath(String binaryName, {String windowsSuffix = 'cmd'}) { + final path = Platform.isWindows + ? '$compilerBinariesDir/$binaryName.$windowsSuffix' + : '$compilerBinariesDir/$binaryName'; + if (!File(path).existsSync()) { + throw StateError('Binary $path not found; is your installed NDK too old?'); + } + return path; + } + + const apiTarget = '35'; + final clangPath = binaryPath('$ndkTargetTriple$apiTarget-clang'); + final clangPpPath = binaryPath('$ndkTargetTriple$apiTarget-clang++'); + final ranlibPath = binaryPath('llvm-ranlib', windowsSuffix: 'exe'); + + final ndkToolchainRoot = Directory(clangPath).parent.parent.path; + final sysroot = '$ndkToolchainRoot/sysroot'; + final extraInclude = '$sysroot/usr/include/$ndkSysrootTargetTriple'; + final bindgenClangArgs = '--sysroot=$sysroot -I$extraInclude'.replaceAll( + r'\', + '/', + ); + + return { + 'AR_$targetTripleEnvVar': cCompiler.archiver.toFilePath(), + 'CC_$targetTripleEnvVar': clangPath, + 'CXX_$targetTripleEnvVar': clangPpPath, + 'RANLIB_$targetTripleEnvVar': ranlibPath, + 'CARGO_TARGET_${targetTripleEnvVar.toUpperCase()}_LINKER': clangPath, + 'BINDGEN_EXTRA_CLANG_ARGS_$targetTripleEnvVar': bindgenClangArgs, + }; +} diff --git a/interop/packages/dart/lib/AmudResult.g.dart b/interop/packages/dart/lib/AmudResult.g.dart new file mode 100644 index 0000000..bd73f9c --- /dev/null +++ b/interop/packages/dart/lib/AmudResult.g.dart @@ -0,0 +1,62 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +final class _AmudResultFfi extends ffi.Struct { + @ffi.Int32() + external int tractate; + @ffi.Uint16() + external int page; + @ffi.Int32() + external int side; +} + +final class AmudResult { + // ignore: public_member_api_docs + TractateCode tractate; + // ignore: public_member_api_docs + int page; + // ignore: public_member_api_docs + SideCode side; + + // ignore: public_member_api_docs + AmudResult({required this.tractate, required this.page, required this.side}); + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + AmudResult._fromFfi(_AmudResultFfi ffi) : + tractate = TractateCode.values[ffi.tractate], + page = ffi.page, + side = SideCode.values[ffi.side]; + + // ignore: unused_element + _AmudResultFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_AmudResultFfi>(); + struct.tractate = tractate.index; + struct.page = page; + struct.side = side.index; + return struct; + } + + + @override + bool operator ==(Object other) => + other is AmudResult && + other.tractate == tractate && + other.page == page && + other.side == side; + + @override + int get hashCode => Object.hashAll([ + tractate, + page, + side, + ]); +} + +// dart format on diff --git a/interop/packages/dart/lib/CalculatorConfig.g.dart b/interop/packages/dart/lib/CalculatorConfig.g.dart new file mode 100644 index 0000000..90a2975 --- /dev/null +++ b/interop/packages/dart/lib/CalculatorConfig.g.dart @@ -0,0 +1,79 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +final class _CalculatorConfigFfi extends ffi.Struct { + @ffi.Int32() + external int candleLightingOffsetMinutes; + @ffi.Bool() + external bool useAstronomicalChatzosForOtherZmanim; + @ffi.Bool() + external bool useElevation; + @ffi.Int32() + external int ateretTorahSunsetOffsetMinutes; + @ffi.Bool() + external bool useAstronomicalChatzos; +} + +/// Calculator configuration (durations in minutes). +final class CalculatorConfig { + // ignore: public_member_api_docs + int candleLightingOffsetMinutes; + // ignore: public_member_api_docs + bool useAstronomicalChatzosForOtherZmanim; + // ignore: public_member_api_docs + bool useElevation; + // ignore: public_member_api_docs + int ateretTorahSunsetOffsetMinutes; + // ignore: public_member_api_docs + bool useAstronomicalChatzos; + + // ignore: public_member_api_docs + CalculatorConfig({required this.candleLightingOffsetMinutes, required this.useAstronomicalChatzosForOtherZmanim, required this.useElevation, required this.ateretTorahSunsetOffsetMinutes, required this.useAstronomicalChatzos}); + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + CalculatorConfig._fromFfi(_CalculatorConfigFfi ffi) : + candleLightingOffsetMinutes = ffi.candleLightingOffsetMinutes, + useAstronomicalChatzosForOtherZmanim = ffi.useAstronomicalChatzosForOtherZmanim, + useElevation = ffi.useElevation, + ateretTorahSunsetOffsetMinutes = ffi.ateretTorahSunsetOffsetMinutes, + useAstronomicalChatzos = ffi.useAstronomicalChatzos; + + // ignore: unused_element + _CalculatorConfigFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_CalculatorConfigFfi>(); + struct.candleLightingOffsetMinutes = candleLightingOffsetMinutes; + struct.useAstronomicalChatzosForOtherZmanim = useAstronomicalChatzosForOtherZmanim; + struct.useElevation = useElevation; + struct.ateretTorahSunsetOffsetMinutes = ateretTorahSunsetOffsetMinutes; + struct.useAstronomicalChatzos = useAstronomicalChatzos; + return struct; + } + + + @override + bool operator ==(Object other) => + other is CalculatorConfig && + other.candleLightingOffsetMinutes == candleLightingOffsetMinutes && + other.useAstronomicalChatzosForOtherZmanim == useAstronomicalChatzosForOtherZmanim && + other.useElevation == useElevation && + other.ateretTorahSunsetOffsetMinutes == ateretTorahSunsetOffsetMinutes && + other.useAstronomicalChatzos == useAstronomicalChatzos; + + @override + int get hashCode => Object.hashAll([ + candleLightingOffsetMinutes, + useAstronomicalChatzosForOtherZmanim, + useElevation, + ateretTorahSunsetOffsetMinutes, + useAstronomicalChatzos, + ]); +} + +// dart format on diff --git a/interop/packages/dart/lib/Calendar.g.dart b/interop/packages/dart/lib/Calendar.g.dart new file mode 100644 index 0000000..98e319d --- /dev/null +++ b/interop/packages/dart/lib/Calendar.g.dart @@ -0,0 +1,202 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +/// Dart entry point: construct once and call instance methods. +final class Calendar implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + Calendar._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + @_DiplomatFfiUse('Calendar_destroy') + static final _finalizer = ffi.NativeFinalizer(ffi.Native.addressOf(_Calendar_destroy)); + + factory Calendar() { + final result = _Calendar_new(); + return Calendar._fromFfi(result, []); + } + + HebrewDate? gregorianToHebrew(CivilDate date) { + final temp = _FinalizedArena(); + final result = _Calendar_gregorian_to_hebrew(_ffi, date._toFfi(temp.arena)); + if (!result.isOk) { + return null; + } + return HebrewDate._fromFfi(result.union.ok); + } + + CivilDate? hebrewToGregorian(HebrewDate date) { + final temp = _FinalizedArena(); + final result = _Calendar_hebrew_to_gregorian(_ffi, date._toFfi(temp.arena)); + if (!result.isOk) { + return null; + } + return CivilDate._fromFfi(result.union.ok); + } + + HolidayList? holidaysOnDate(CivilDate date, bool inIsrael, bool useModernHolidays) { + final temp = _FinalizedArena(); + final result = _Calendar_holidays_on_date(_ffi, date._toFfi(temp.arena), inIsrael, useModernHolidays); + return result.address == 0 ? null : HolidayList._fromFfi(result, []); + } + + bool? isAssurBemelacha(CivilDate date, bool inIsrael) { + final temp = _FinalizedArena(); + final result = _Calendar_is_assur_bemelacha(_ffi, date._toFfi(temp.arena), inIsrael); + if (!result.isOk) { + return null; + } + return result.union.ok; + } + + bool? hasCandleLighting(CivilDate date, bool inIsrael) { + final temp = _FinalizedArena(); + final result = _Calendar_has_candle_lighting(_ffi, date._toFfi(temp.arena), inIsrael); + if (!result.isOk) { + return null; + } + return result.union.ok; + } + + ParshaCode? todaysParsha(CivilDate date, bool inIsrael) { + final temp = _FinalizedArena(); + final result = _Calendar_todays_parsha(_ffi, date._toFfi(temp.arena), inIsrael); + if (!result.isOk) { + return null; + } + return ParshaCode.values[result.union.ok]; + } + + ParshaCode? specialParsha(CivilDate date, bool inIsrael) { + final temp = _FinalizedArena(); + final result = _Calendar_special_parsha(_ffi, date._toFfi(temp.arena), inIsrael); + if (!result.isOk) { + return null; + } + return ParshaCode.values[result.union.ok]; + } + + ParshaCode? upcomingParsha(CivilDate date, bool inIsrael) { + final temp = _FinalizedArena(); + final result = _Calendar_upcoming_parsha(_ffi, date._toFfi(temp.arena), inIsrael); + if (!result.isOk) { + return null; + } + return ParshaCode.values[result.union.ok]; + } + + int? daysInHebrewYear(int year) { + final result = _Calendar_days_in_hebrew_year(_ffi, year); + if (!result.isOk) { + return null; + } + return result.union.ok; + } + + int? daysInHebrewMonth(int year, int month) { + final result = _Calendar_days_in_hebrew_month(_ffi, year, month); + if (!result.isOk) { + return null; + } + return result.union.ok; + } + + bool isHebrewLeapYear(int year) { + final result = _Calendar_is_hebrew_leap_year(_ffi, year); + return result; + } + + YearLengthTypeCode? cheshvanKislevKviah(int year) { + final result = _Calendar_cheshvan_kislev_kviah(_ffi, year); + if (!result.isOk) { + return null; + } + return YearLengthTypeCode.values[result.union.ok]; + } + +} + +@_DiplomatFfiUse('Calendar_destroy') +@ffi.Native)>(isLeaf: true, symbol: 'Calendar_destroy') +// ignore: non_constant_identifier_names +external void _Calendar_destroy(ffi.Pointer self); + +@_DiplomatFfiUse('Calendar_new') +@ffi.Native Function()>(isLeaf: true, symbol: 'Calendar_new') +// ignore: non_constant_identifier_names +external ffi.Pointer _Calendar_new(); + +@_DiplomatFfiUse('Calendar_gregorian_to_hebrew') +@ffi.Native<_ResultHebrewDateFfiVoid Function(ffi.Pointer, _CivilDateFfi)>(isLeaf: true, symbol: 'Calendar_gregorian_to_hebrew') +// ignore: non_constant_identifier_names +external _ResultHebrewDateFfiVoid _Calendar_gregorian_to_hebrew(ffi.Pointer self, _CivilDateFfi date); + +@_DiplomatFfiUse('Calendar_hebrew_to_gregorian') +@ffi.Native<_ResultCivilDateFfiVoid Function(ffi.Pointer, _HebrewDateFfi)>(isLeaf: true, symbol: 'Calendar_hebrew_to_gregorian') +// ignore: non_constant_identifier_names +external _ResultCivilDateFfiVoid _Calendar_hebrew_to_gregorian(ffi.Pointer self, _HebrewDateFfi date); + +@_DiplomatFfiUse('Calendar_holidays_on_date') +@ffi.Native Function(ffi.Pointer, _CivilDateFfi, ffi.Bool, ffi.Bool)>(isLeaf: true, symbol: 'Calendar_holidays_on_date') +// ignore: non_constant_identifier_names +external ffi.Pointer _Calendar_holidays_on_date(ffi.Pointer self, _CivilDateFfi date, bool inIsrael, bool useModernHolidays); + +@_DiplomatFfiUse('Calendar_is_assur_bemelacha') +@ffi.Native<_ResultBoolVoid Function(ffi.Pointer, _CivilDateFfi, ffi.Bool)>(isLeaf: true, symbol: 'Calendar_is_assur_bemelacha') +// ignore: non_constant_identifier_names +external _ResultBoolVoid _Calendar_is_assur_bemelacha(ffi.Pointer self, _CivilDateFfi date, bool inIsrael); + +@_DiplomatFfiUse('Calendar_has_candle_lighting') +@ffi.Native<_ResultBoolVoid Function(ffi.Pointer, _CivilDateFfi, ffi.Bool)>(isLeaf: true, symbol: 'Calendar_has_candle_lighting') +// ignore: non_constant_identifier_names +external _ResultBoolVoid _Calendar_has_candle_lighting(ffi.Pointer self, _CivilDateFfi date, bool inIsrael); + +@_DiplomatFfiUse('Calendar_todays_parsha') +@ffi.Native<_ResultInt32Void Function(ffi.Pointer, _CivilDateFfi, ffi.Bool)>(isLeaf: true, symbol: 'Calendar_todays_parsha') +// ignore: non_constant_identifier_names +external _ResultInt32Void _Calendar_todays_parsha(ffi.Pointer self, _CivilDateFfi date, bool inIsrael); + +@_DiplomatFfiUse('Calendar_special_parsha') +@ffi.Native<_ResultInt32Void Function(ffi.Pointer, _CivilDateFfi, ffi.Bool)>(isLeaf: true, symbol: 'Calendar_special_parsha') +// ignore: non_constant_identifier_names +external _ResultInt32Void _Calendar_special_parsha(ffi.Pointer self, _CivilDateFfi date, bool inIsrael); + +@_DiplomatFfiUse('Calendar_upcoming_parsha') +@ffi.Native<_ResultInt32Void Function(ffi.Pointer, _CivilDateFfi, ffi.Bool)>(isLeaf: true, symbol: 'Calendar_upcoming_parsha') +// ignore: non_constant_identifier_names +external _ResultInt32Void _Calendar_upcoming_parsha(ffi.Pointer self, _CivilDateFfi date, bool inIsrael); + +@_DiplomatFfiUse('Calendar_days_in_hebrew_year') +@ffi.Native<_ResultInt32Void Function(ffi.Pointer, ffi.Int32)>(isLeaf: true, symbol: 'Calendar_days_in_hebrew_year') +// ignore: non_constant_identifier_names +external _ResultInt32Void _Calendar_days_in_hebrew_year(ffi.Pointer self, int year); + +@_DiplomatFfiUse('Calendar_days_in_hebrew_month') +@ffi.Native<_ResultUint8Void Function(ffi.Pointer, ffi.Int32, ffi.Uint8)>(isLeaf: true, symbol: 'Calendar_days_in_hebrew_month') +// ignore: non_constant_identifier_names +external _ResultUint8Void _Calendar_days_in_hebrew_month(ffi.Pointer self, int year, int month); + +@_DiplomatFfiUse('Calendar_is_hebrew_leap_year') +@ffi.Native, ffi.Int32)>(isLeaf: true, symbol: 'Calendar_is_hebrew_leap_year') +// ignore: non_constant_identifier_names +external bool _Calendar_is_hebrew_leap_year(ffi.Pointer self, int year); + +@_DiplomatFfiUse('Calendar_cheshvan_kislev_kviah') +@ffi.Native<_ResultInt32Void Function(ffi.Pointer, ffi.Int32)>(isLeaf: true, symbol: 'Calendar_cheshvan_kislev_kviah') +// ignore: non_constant_identifier_names +external _ResultInt32Void _Calendar_cheshvan_kislev_kviah(ffi.Pointer self, int year); + +// dart format on diff --git a/interop/packages/dart/lib/CivilDate.g.dart b/interop/packages/dart/lib/CivilDate.g.dart new file mode 100644 index 0000000..9b1e92f --- /dev/null +++ b/interop/packages/dart/lib/CivilDate.g.dart @@ -0,0 +1,63 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +final class _CivilDateFfi extends ffi.Struct { + @ffi.Int32() + external int year; + @ffi.Uint8() + external int month; + @ffi.Uint8() + external int day; +} + +/// Gregorian civil date (year, month, day). +final class CivilDate { + // ignore: public_member_api_docs + int year; + // ignore: public_member_api_docs + int month; + // ignore: public_member_api_docs + int day; + + // ignore: public_member_api_docs + CivilDate({required this.year, required this.month, required this.day}); + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + CivilDate._fromFfi(_CivilDateFfi ffi) : + year = ffi.year, + month = ffi.month, + day = ffi.day; + + // ignore: unused_element + _CivilDateFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_CivilDateFfi>(); + struct.year = year; + struct.month = month; + struct.day = day; + return struct; + } + + + @override + bool operator ==(Object other) => + other is CivilDate && + other.year == year && + other.month == month && + other.day == day; + + @override + int get hashCode => Object.hashAll([ + year, + month, + day, + ]); +} + +// dart format on diff --git a/interop/packages/dart/lib/DafResult.g.dart b/interop/packages/dart/lib/DafResult.g.dart new file mode 100644 index 0000000..24b323a --- /dev/null +++ b/interop/packages/dart/lib/DafResult.g.dart @@ -0,0 +1,54 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +final class _DafResultFfi extends ffi.Struct { + @ffi.Int32() + external int tractate; + @ffi.Uint16() + external int page; +} + +final class DafResult { + // ignore: public_member_api_docs + TractateCode tractate; + // ignore: public_member_api_docs + int page; + + // ignore: public_member_api_docs + DafResult({required this.tractate, required this.page}); + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + DafResult._fromFfi(_DafResultFfi ffi) : + tractate = TractateCode.values[ffi.tractate], + page = ffi.page; + + // ignore: unused_element + _DafResultFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_DafResultFfi>(); + struct.tractate = tractate.index; + struct.page = page; + return struct; + } + + + @override + bool operator ==(Object other) => + other is DafResult && + other.tractate == tractate && + other.page == page; + + @override + int get hashCode => Object.hashAll([ + tractate, + page, + ]); +} + +// dart format on diff --git a/interop/packages/dart/lib/FfiLocation.g.dart b/interop/packages/dart/lib/FfiLocation.g.dart new file mode 100644 index 0000000..d1c0a2c --- /dev/null +++ b/interop/packages/dart/lib/FfiLocation.g.dart @@ -0,0 +1,50 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +final class FfiLocation implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + FfiLocation._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + @_DiplomatFfiUse('FfiLocation_destroy') + static final _finalizer = ffi.NativeFinalizer(ffi.Native.addressOf(_FfiLocation_destroy)); + + /// Creates a location. Pass an empty timezone string when unknown. + /// + /// Throws [ZmanimErrorCode] on failure. + static FfiLocation new_(double latitude, double longitude, double elevation, String timezoneIana) { + final temp = _FinalizedArena(); + final result = _FfiLocation_new(latitude, longitude, elevation, timezoneIana._utf8AllocIn(temp.arena)); + if (!result.isOk) { + throw ZmanimErrorCode.values[result.union.err]; + } + return FfiLocation._fromFfi(result.union.ok, []); + } + +} + +@_DiplomatFfiUse('FfiLocation_destroy') +@ffi.Native)>(isLeaf: true, symbol: 'FfiLocation_destroy') +// ignore: non_constant_identifier_names +external void _FfiLocation_destroy(ffi.Pointer self); + +@_DiplomatFfiUse('FfiLocation_new') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Double, ffi.Double, ffi.Double, _SliceUtf8)>(isLeaf: true, symbol: 'FfiLocation_new') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _FfiLocation_new(double latitude, double longitude, double elevation, _SliceUtf8 timezoneIana); + +// dart format on diff --git a/interop/packages/dart/lib/FfiZmanimCalculator.g.dart b/interop/packages/dart/lib/FfiZmanimCalculator.g.dart new file mode 100644 index 0000000..979894e --- /dev/null +++ b/interop/packages/dart/lib/FfiZmanimCalculator.g.dart @@ -0,0 +1,62 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +final class FfiZmanimCalculator implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + FfiZmanimCalculator._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + @_DiplomatFfiUse('FfiZmanimCalculator_destroy') + static final _finalizer = ffi.NativeFinalizer(ffi.Native.addressOf(_FfiZmanimCalculator_destroy)); + + static FfiZmanimCalculator? new_(FfiLocation location, int year, int month, int day, CalculatorConfig config) { + final temp = _FinalizedArena(); + final result = _FfiZmanimCalculator_new(location._ffi, year, month, day, config._toFfi(temp.arena)); + return result.address == 0 ? null : FfiZmanimCalculator._fromFfi(result, []); + } + + /// Calculates a zman preset by index, returning UTC epoch milliseconds. + /// + /// The index matches [ZmanPresetId] in the generated [crate::zman_preset] module. + /// + /// Throws [ZmanimErrorCode] on failure. + int calculateZmanByIndex(int presetIndex) { + final result = _FfiZmanimCalculator_calculate_zman_by_index(_ffi, presetIndex); + if (!result.isOk) { + throw ZmanimErrorCode.values[result.union.err]; + } + return result.union.ok; + } + +} + +@_DiplomatFfiUse('FfiZmanimCalculator_destroy') +@ffi.Native)>(isLeaf: true, symbol: 'FfiZmanimCalculator_destroy') +// ignore: non_constant_identifier_names +external void _FfiZmanimCalculator_destroy(ffi.Pointer self); + +@_DiplomatFfiUse('FfiZmanimCalculator_new') +@ffi.Native Function(ffi.Pointer, ffi.Int32, ffi.Uint8, ffi.Uint8, _CalculatorConfigFfi)>(isLeaf: true, symbol: 'FfiZmanimCalculator_new') +// ignore: non_constant_identifier_names +external ffi.Pointer _FfiZmanimCalculator_new(ffi.Pointer location, int year, int month, int day, _CalculatorConfigFfi config); + +@_DiplomatFfiUse('FfiZmanimCalculator_calculate_zman_by_index') +@ffi.Native<_ResultInt64Int32 Function(ffi.Pointer, ffi.Uint32)>(isLeaf: true, symbol: 'FfiZmanimCalculator_calculate_zman_by_index') +// ignore: non_constant_identifier_names +external _ResultInt64Int32 _FfiZmanimCalculator_calculate_zman_by_index(ffi.Pointer self, int presetIndex); + +// dart format on diff --git a/interop/packages/dart/lib/HebrewDate.g.dart b/interop/packages/dart/lib/HebrewDate.g.dart new file mode 100644 index 0000000..db5558a --- /dev/null +++ b/interop/packages/dart/lib/HebrewDate.g.dart @@ -0,0 +1,63 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +final class _HebrewDateFfi extends ffi.Struct { + @ffi.Int32() + external int year; + @ffi.Uint8() + external int month; + @ffi.Uint8() + external int day; +} + +/// Hebrew calendar date (year, month code, day). +final class HebrewDate { + // ignore: public_member_api_docs + int year; + // ignore: public_member_api_docs + int month; + // ignore: public_member_api_docs + int day; + + // ignore: public_member_api_docs + HebrewDate({required this.year, required this.month, required this.day}); + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + HebrewDate._fromFfi(_HebrewDateFfi ffi) : + year = ffi.year, + month = ffi.month, + day = ffi.day; + + // ignore: unused_element + _HebrewDateFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_HebrewDateFfi>(); + struct.year = year; + struct.month = month; + struct.day = day; + return struct; + } + + + @override + bool operator ==(Object other) => + other is HebrewDate && + other.year == year && + other.month == month && + other.day == day; + + @override + int get hashCode => Object.hashAll([ + year, + month, + day, + ]); +} + +// dart format on diff --git a/interop/packages/dart/lib/HolidayCode.g.dart b/interop/packages/dart/lib/HolidayCode.g.dart new file mode 100644 index 0000000..449b9c1 --- /dev/null +++ b/interop/packages/dart/lib/HolidayCode.g.dart @@ -0,0 +1,94 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +enum HolidayCode { + // ignore: public_member_api_docs + erevPesach, + // ignore: public_member_api_docs + pesach, + // ignore: public_member_api_docs + cholHamoedPesach, + // ignore: public_member_api_docs + pesachSheni, + // ignore: public_member_api_docs + erevShavuos, + // ignore: public_member_api_docs + shavuos, + // ignore: public_member_api_docs + seventeenthOfTammuz, + // ignore: public_member_api_docs + tishahBav, + // ignore: public_member_api_docs + tuBav, + // ignore: public_member_api_docs + erevRoshHashana, + // ignore: public_member_api_docs + roshHashana, + // ignore: public_member_api_docs + fastOfGedalyah, + // ignore: public_member_api_docs + erevYomKippur, + // ignore: public_member_api_docs + yomKippur, + // ignore: public_member_api_docs + erevSuccos, + // ignore: public_member_api_docs + succos, + // ignore: public_member_api_docs + cholHamoedSuccos, + // ignore: public_member_api_docs + hoshanaRabbah, + // ignore: public_member_api_docs + sheminiAtzeres, + // ignore: public_member_api_docs + simchasTorah, + // ignore: public_member_api_docs + chanukah, + // ignore: public_member_api_docs + tenthOfTeves, + // ignore: public_member_api_docs + tuBshvat, + // ignore: public_member_api_docs + fastOfEsther, + // ignore: public_member_api_docs + purim, + // ignore: public_member_api_docs + shushanPurim, + // ignore: public_member_api_docs + purimKatan, + // ignore: public_member_api_docs + roshChodesh, + // ignore: public_member_api_docs + yomHaShoah, + // ignore: public_member_api_docs + yomHazikaron, + // ignore: public_member_api_docs + yomHaatzmaut, + // ignore: public_member_api_docs + yomYerushalayim, + // ignore: public_member_api_docs + lagBomer, + // ignore: public_member_api_docs + shushanPurimKatan, + // ignore: public_member_api_docs + isruChag, + // ignore: public_member_api_docs + yomKippurKatan, + // ignore: public_member_api_docs + behab, + // ignore: public_member_api_docs + fastOfTheFirstborn, + // ignore: public_member_api_docs + countOfTheOmer, + // ignore: public_member_api_docs + birchasHachamah, + // ignore: public_member_api_docs + macharHachodesh, + // ignore: public_member_api_docs + shabbosMevarchim; + +} + +// dart format on diff --git a/interop/packages/dart/lib/HolidayEntry.g.dart b/interop/packages/dart/lib/HolidayEntry.g.dart new file mode 100644 index 0000000..1d0b0c4 --- /dev/null +++ b/interop/packages/dart/lib/HolidayEntry.g.dart @@ -0,0 +1,55 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +final class _HolidayEntryFfi extends ffi.Struct { + @ffi.Int32() + external int code; + @ffi.Uint8() + external int subDay; +} + +/// A holiday occurring on a date, with an optional sub-day (Chanukah, Omer). +final class HolidayEntry { + // ignore: public_member_api_docs + HolidayCode code; + // ignore: public_member_api_docs + int subDay; + + // ignore: public_member_api_docs + HolidayEntry({required this.code, required this.subDay}); + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + HolidayEntry._fromFfi(_HolidayEntryFfi ffi) : + code = HolidayCode.values[ffi.code], + subDay = ffi.subDay; + + // ignore: unused_element + _HolidayEntryFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_HolidayEntryFfi>(); + struct.code = code.index; + struct.subDay = subDay; + return struct; + } + + + @override + bool operator ==(Object other) => + other is HolidayEntry && + other.code == code && + other.subDay == subDay; + + @override + int get hashCode => Object.hashAll([ + code, + subDay, + ]); +} + +// dart format on diff --git a/interop/packages/dart/lib/HolidayList.g.dart b/interop/packages/dart/lib/HolidayList.g.dart new file mode 100644 index 0000000..418a50c --- /dev/null +++ b/interop/packages/dart/lib/HolidayList.g.dart @@ -0,0 +1,56 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +final class HolidayList implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + HolidayList._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + @_DiplomatFfiUse('HolidayList_destroy') + static final _finalizer = ffi.NativeFinalizer(ffi.Native.addressOf(_HolidayList_destroy)); + + int len() { + final result = _HolidayList_len(_ffi); + return result; + } + + HolidayEntry? get(int index) { + final result = _HolidayList_get(_ffi, index); + if (!result.isOk) { + return null; + } + return HolidayEntry._fromFfi(result.union.ok); + } + +} + +@_DiplomatFfiUse('HolidayList_destroy') +@ffi.Native)>(isLeaf: true, symbol: 'HolidayList_destroy') +// ignore: non_constant_identifier_names +external void _HolidayList_destroy(ffi.Pointer self); + +@_DiplomatFfiUse('HolidayList_len') +@ffi.Native)>(isLeaf: true, symbol: 'HolidayList_len') +// ignore: non_constant_identifier_names +external int _HolidayList_len(ffi.Pointer self); + +@_DiplomatFfiUse('HolidayList_get') +@ffi.Native<_ResultHolidayEntryFfiVoid Function(ffi.Pointer, ffi.Uint32)>(isLeaf: true, symbol: 'HolidayList_get') +// ignore: non_constant_identifier_names +external _ResultHolidayEntryFfiVoid _HolidayList_get(ffi.Pointer self, int index); + +// dart format on diff --git a/interop/packages/dart/lib/Limudim.g.dart b/interop/packages/dart/lib/Limudim.g.dart new file mode 100644 index 0000000..b8d957f --- /dev/null +++ b/interop/packages/dart/lib/Limudim.g.dart @@ -0,0 +1,135 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +/// Dart entry point: construct once and call instance methods. +final class Limudim implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + Limudim._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + @_DiplomatFfiUse('Limudim_destroy') + static final _finalizer = ffi.NativeFinalizer(ffi.Native.addressOf(_Limudim_destroy)); + + factory Limudim() { + final result = _Limudim_new(); + return Limudim._fromFfi(result, []); + } + + DafResult? dafYomiBavli(int year, int month, int day) { + final result = _Limudim_daf_yomi_bavli(_ffi, year, month, day); + if (!result.isOk) { + return null; + } + return DafResult._fromFfi(result.union.ok); + } + + DafResult? dafYomiYerushalmi(int year, int month, int day) { + final result = _Limudim_daf_yomi_yerushalmi(_ffi, year, month, day); + if (!result.isOk) { + return null; + } + return DafResult._fromFfi(result.union.ok); + } + + DafResult? dafHashavuaBavli(int year, int month, int day) { + final result = _Limudim_daf_hashavua_bavli(_ffi, year, month, day); + if (!result.isOk) { + return null; + } + return DafResult._fromFfi(result.union.ok); + } + + AmudResult? amudYomiBavliDirshu(int year, int month, int day) { + final result = _Limudim_amud_yomi_bavli_dirshu(_ffi, year, month, day); + if (!result.isOk) { + return null; + } + return AmudResult._fromFfi(result.union.ok); + } + + MishnasResult? mishnaYomis(int year, int month, int day) { + final result = _Limudim_mishna_yomis(_ffi, year, month, day); + if (!result.isOk) { + return null; + } + return MishnasResult._fromFfi(result.union.ok); + } + + PirkeiAvosResult? pirkeiAvos(int year, int month, int day, bool inIsrael) { + final result = _Limudim_pirkei_avos(_ffi, year, month, day, inIsrael); + if (!result.isOk) { + return null; + } + return PirkeiAvosResult._fromFfi(result.union.ok); + } + + TehillimResult? tehillimMonthly(int year, int month, int day) { + final result = _Limudim_tehillim_monthly(_ffi, year, month, day); + if (!result.isOk) { + return null; + } + return TehillimResult._fromFfi(result.union.ok); + } + +} + +@_DiplomatFfiUse('Limudim_destroy') +@ffi.Native)>(isLeaf: true, symbol: 'Limudim_destroy') +// ignore: non_constant_identifier_names +external void _Limudim_destroy(ffi.Pointer self); + +@_DiplomatFfiUse('Limudim_new') +@ffi.Native Function()>(isLeaf: true, symbol: 'Limudim_new') +// ignore: non_constant_identifier_names +external ffi.Pointer _Limudim_new(); + +@_DiplomatFfiUse('Limudim_daf_yomi_bavli') +@ffi.Native<_ResultDafResultFfiVoid Function(ffi.Pointer, ffi.Int32, ffi.Uint8, ffi.Uint8)>(isLeaf: true, symbol: 'Limudim_daf_yomi_bavli') +// ignore: non_constant_identifier_names +external _ResultDafResultFfiVoid _Limudim_daf_yomi_bavli(ffi.Pointer self, int year, int month, int day); + +@_DiplomatFfiUse('Limudim_daf_yomi_yerushalmi') +@ffi.Native<_ResultDafResultFfiVoid Function(ffi.Pointer, ffi.Int32, ffi.Uint8, ffi.Uint8)>(isLeaf: true, symbol: 'Limudim_daf_yomi_yerushalmi') +// ignore: non_constant_identifier_names +external _ResultDafResultFfiVoid _Limudim_daf_yomi_yerushalmi(ffi.Pointer self, int year, int month, int day); + +@_DiplomatFfiUse('Limudim_daf_hashavua_bavli') +@ffi.Native<_ResultDafResultFfiVoid Function(ffi.Pointer, ffi.Int32, ffi.Uint8, ffi.Uint8)>(isLeaf: true, symbol: 'Limudim_daf_hashavua_bavli') +// ignore: non_constant_identifier_names +external _ResultDafResultFfiVoid _Limudim_daf_hashavua_bavli(ffi.Pointer self, int year, int month, int day); + +@_DiplomatFfiUse('Limudim_amud_yomi_bavli_dirshu') +@ffi.Native<_ResultAmudResultFfiVoid Function(ffi.Pointer, ffi.Int32, ffi.Uint8, ffi.Uint8)>(isLeaf: true, symbol: 'Limudim_amud_yomi_bavli_dirshu') +// ignore: non_constant_identifier_names +external _ResultAmudResultFfiVoid _Limudim_amud_yomi_bavli_dirshu(ffi.Pointer self, int year, int month, int day); + +@_DiplomatFfiUse('Limudim_mishna_yomis') +@ffi.Native<_ResultMishnasResultFfiVoid Function(ffi.Pointer, ffi.Int32, ffi.Uint8, ffi.Uint8)>(isLeaf: true, symbol: 'Limudim_mishna_yomis') +// ignore: non_constant_identifier_names +external _ResultMishnasResultFfiVoid _Limudim_mishna_yomis(ffi.Pointer self, int year, int month, int day); + +@_DiplomatFfiUse('Limudim_pirkei_avos') +@ffi.Native<_ResultPirkeiAvosResultFfiVoid Function(ffi.Pointer, ffi.Int32, ffi.Uint8, ffi.Uint8, ffi.Bool)>(isLeaf: true, symbol: 'Limudim_pirkei_avos') +// ignore: non_constant_identifier_names +external _ResultPirkeiAvosResultFfiVoid _Limudim_pirkei_avos(ffi.Pointer self, int year, int month, int day, bool inIsrael); + +@_DiplomatFfiUse('Limudim_tehillim_monthly') +@ffi.Native<_ResultTehillimResultFfiVoid Function(ffi.Pointer, ffi.Int32, ffi.Uint8, ffi.Uint8)>(isLeaf: true, symbol: 'Limudim_tehillim_monthly') +// ignore: non_constant_identifier_names +external _ResultTehillimResultFfiVoid _Limudim_tehillim_monthly(ffi.Pointer self, int year, int month, int day); + +// dart format on diff --git a/interop/packages/dart/lib/MishnaResult.g.dart b/interop/packages/dart/lib/MishnaResult.g.dart new file mode 100644 index 0000000..4d4029b --- /dev/null +++ b/interop/packages/dart/lib/MishnaResult.g.dart @@ -0,0 +1,62 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +final class _MishnaResultFfi extends ffi.Struct { + @ffi.Int32() + external int tractate; + @ffi.Size() + external int chapter; + @ffi.Uint16() + external int mishna; +} + +final class MishnaResult { + // ignore: public_member_api_docs + TractateCode tractate; + // ignore: public_member_api_docs + int chapter; + // ignore: public_member_api_docs + int mishna; + + // ignore: public_member_api_docs + MishnaResult({required this.tractate, required this.chapter, required this.mishna}); + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + MishnaResult._fromFfi(_MishnaResultFfi ffi) : + tractate = TractateCode.values[ffi.tractate], + chapter = ffi.chapter, + mishna = ffi.mishna; + + // ignore: unused_element + _MishnaResultFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_MishnaResultFfi>(); + struct.tractate = tractate.index; + struct.chapter = chapter; + struct.mishna = mishna; + return struct; + } + + + @override + bool operator ==(Object other) => + other is MishnaResult && + other.tractate == tractate && + other.chapter == chapter && + other.mishna == mishna; + + @override + int get hashCode => Object.hashAll([ + tractate, + chapter, + mishna, + ]); +} + +// dart format on diff --git a/interop/packages/dart/lib/MishnasResult.g.dart b/interop/packages/dart/lib/MishnasResult.g.dart new file mode 100644 index 0000000..8cb6d9d --- /dev/null +++ b/interop/packages/dart/lib/MishnasResult.g.dart @@ -0,0 +1,52 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +final class _MishnasResultFfi extends ffi.Struct { + external _MishnaResultFfi start; + external _MishnaResultFfi end; +} + +final class MishnasResult { + // ignore: public_member_api_docs + MishnaResult start; + // ignore: public_member_api_docs + MishnaResult end; + + // ignore: public_member_api_docs + MishnasResult({required this.start, required this.end}); + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + MishnasResult._fromFfi(_MishnasResultFfi ffi) : + start = MishnaResult._fromFfi(ffi.start), + end = MishnaResult._fromFfi(ffi.end); + + // ignore: unused_element + _MishnasResultFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_MishnasResultFfi>(); + struct.start = start._toFfi(temp); + struct.end = end._toFfi(temp); + return struct; + } + + + @override + bool operator ==(Object other) => + other is MishnasResult && + other.start == start && + other.end == end; + + @override + int get hashCode => Object.hashAll([ + start, + end, + ]); +} + +// dart format on diff --git a/interop/packages/dart/lib/ParshaCode.g.dart b/interop/packages/dart/lib/ParshaCode.g.dart new file mode 100644 index 0000000..24e3b4c --- /dev/null +++ b/interop/packages/dart/lib/ParshaCode.g.dart @@ -0,0 +1,150 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +enum ParshaCode { + // ignore: public_member_api_docs + bereshis, + // ignore: public_member_api_docs + noach, + // ignore: public_member_api_docs + lechLecha, + // ignore: public_member_api_docs + vayera, + // ignore: public_member_api_docs + chayeiSara, + // ignore: public_member_api_docs + toldos, + // ignore: public_member_api_docs + vayetzei, + // ignore: public_member_api_docs + vayishlach, + // ignore: public_member_api_docs + vayeshev, + // ignore: public_member_api_docs + miketz, + // ignore: public_member_api_docs + vayigash, + // ignore: public_member_api_docs + vayechi, + // ignore: public_member_api_docs + shemos, + // ignore: public_member_api_docs + vaera, + // ignore: public_member_api_docs + bo, + // ignore: public_member_api_docs + beshalach, + // ignore: public_member_api_docs + yisro, + // ignore: public_member_api_docs + mishpatim, + // ignore: public_member_api_docs + terumah, + // ignore: public_member_api_docs + tetzaveh, + // ignore: public_member_api_docs + kiSisa, + // ignore: public_member_api_docs + vayakhel, + // ignore: public_member_api_docs + pekudei, + // ignore: public_member_api_docs + vayikra, + // ignore: public_member_api_docs + tzav, + // ignore: public_member_api_docs + shmini, + // ignore: public_member_api_docs + tazria, + // ignore: public_member_api_docs + metzora, + // ignore: public_member_api_docs + achreiMos, + // ignore: public_member_api_docs + kedoshim, + // ignore: public_member_api_docs + emor, + // ignore: public_member_api_docs + behar, + // ignore: public_member_api_docs + bechukosai, + // ignore: public_member_api_docs + bamidbar, + // ignore: public_member_api_docs + nasso, + // ignore: public_member_api_docs + behaaloscha, + // ignore: public_member_api_docs + shlach, + // ignore: public_member_api_docs + korach, + // ignore: public_member_api_docs + chukas, + // ignore: public_member_api_docs + balak, + // ignore: public_member_api_docs + pinchas, + // ignore: public_member_api_docs + matos, + // ignore: public_member_api_docs + masei, + // ignore: public_member_api_docs + devarim, + // ignore: public_member_api_docs + vaeschanan, + // ignore: public_member_api_docs + eikev, + // ignore: public_member_api_docs + reeh, + // ignore: public_member_api_docs + shoftim, + // ignore: public_member_api_docs + kiSeitzei, + // ignore: public_member_api_docs + kiSavo, + // ignore: public_member_api_docs + nitzavim, + // ignore: public_member_api_docs + vayeilech, + // ignore: public_member_api_docs + haAzinu, + // ignore: public_member_api_docs + vezosHabracha, + // ignore: public_member_api_docs + vayakhelPekudei, + // ignore: public_member_api_docs + tazriaMetzora, + // ignore: public_member_api_docs + achreiMosKedoshim, + // ignore: public_member_api_docs + beharBechukosai, + // ignore: public_member_api_docs + chukasBalak, + // ignore: public_member_api_docs + matosMasei, + // ignore: public_member_api_docs + nitzavimVayeilech, + // ignore: public_member_api_docs + shekalim, + // ignore: public_member_api_docs + zachor, + // ignore: public_member_api_docs + parah, + // ignore: public_member_api_docs + hachodesh, + // ignore: public_member_api_docs + shuva, + // ignore: public_member_api_docs + shira, + // ignore: public_member_api_docs + hagadol, + // ignore: public_member_api_docs + chazon, + // ignore: public_member_api_docs + nachamu; + +} + +// dart format on diff --git a/interop/packages/dart/lib/PirkeiAvosResult.g.dart b/interop/packages/dart/lib/PirkeiAvosResult.g.dart new file mode 100644 index 0000000..6f869eb --- /dev/null +++ b/interop/packages/dart/lib/PirkeiAvosResult.g.dart @@ -0,0 +1,63 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +final class _PirkeiAvosResultFfi extends ffi.Struct { + @ffi.Uint8() + external int kind; + @ffi.Uint8() + external int perek1; + @ffi.Uint8() + external int perek2; +} + +/// Flat tagged union for Pirkei Avos (`kind`: 0 = single, 1 = combined). +final class PirkeiAvosResult { + // ignore: public_member_api_docs + int kind; + // ignore: public_member_api_docs + int perek1; + // ignore: public_member_api_docs + int perek2; + + // ignore: public_member_api_docs + PirkeiAvosResult({required this.kind, required this.perek1, required this.perek2}); + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + PirkeiAvosResult._fromFfi(_PirkeiAvosResultFfi ffi) : + kind = ffi.kind, + perek1 = ffi.perek1, + perek2 = ffi.perek2; + + // ignore: unused_element + _PirkeiAvosResultFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_PirkeiAvosResultFfi>(); + struct.kind = kind; + struct.perek1 = perek1; + struct.perek2 = perek2; + return struct; + } + + + @override + bool operator ==(Object other) => + other is PirkeiAvosResult && + other.kind == kind && + other.perek1 == perek1 && + other.perek2 == perek2; + + @override + int get hashCode => Object.hashAll([ + kind, + perek1, + perek2, + ]); +} + +// dart format on diff --git a/interop/packages/dart/lib/SideCode.g.dart b/interop/packages/dart/lib/SideCode.g.dart new file mode 100644 index 0000000..a948926 --- /dev/null +++ b/interop/packages/dart/lib/SideCode.g.dart @@ -0,0 +1,14 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +enum SideCode { + // ignore: public_member_api_docs + aleph, + // ignore: public_member_api_docs + bet; + +} + +// dart format on diff --git a/interop/packages/dart/lib/TehillimResult.g.dart b/interop/packages/dart/lib/TehillimResult.g.dart new file mode 100644 index 0000000..6786bca --- /dev/null +++ b/interop/packages/dart/lib/TehillimResult.g.dart @@ -0,0 +1,87 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +final class _TehillimResultFfi extends ffi.Struct { + @ffi.Uint8() + external int kind; + @ffi.Uint8() + external int start; + @ffi.Uint8() + external int end; + @ffi.Uint8() + external int psalm; + @ffi.Uint16() + external int startVerse; + @ffi.Uint16() + external int endVerse; +} + +/// Flat tagged union for Tehillim (`kind`: 0 = psalms range, 1 = verse range). +final class TehillimResult { + // ignore: public_member_api_docs + int kind; + // ignore: public_member_api_docs + int start; + // ignore: public_member_api_docs + int end; + // ignore: public_member_api_docs + int psalm; + // ignore: public_member_api_docs + int startVerse; + // ignore: public_member_api_docs + int endVerse; + + // ignore: public_member_api_docs + TehillimResult({required this.kind, required this.start, required this.end, required this.psalm, required this.startVerse, required this.endVerse}); + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + TehillimResult._fromFfi(_TehillimResultFfi ffi) : + kind = ffi.kind, + start = ffi.start, + end = ffi.end, + psalm = ffi.psalm, + startVerse = ffi.startVerse, + endVerse = ffi.endVerse; + + // ignore: unused_element + _TehillimResultFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_TehillimResultFfi>(); + struct.kind = kind; + struct.start = start; + struct.end = end; + struct.psalm = psalm; + struct.startVerse = startVerse; + struct.endVerse = endVerse; + return struct; + } + + + @override + bool operator ==(Object other) => + other is TehillimResult && + other.kind == kind && + other.start == start && + other.end == end && + other.psalm == psalm && + other.startVerse == startVerse && + other.endVerse == endVerse; + + @override + int get hashCode => Object.hashAll([ + kind, + start, + end, + psalm, + startVerse, + endVerse, + ]); +} + +// dart format on diff --git a/interop/packages/dart/lib/TractateCode.g.dart b/interop/packages/dart/lib/TractateCode.g.dart new file mode 100644 index 0000000..6367ca6 --- /dev/null +++ b/interop/packages/dart/lib/TractateCode.g.dart @@ -0,0 +1,136 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +enum TractateCode { + // ignore: public_member_api_docs + berachos, + // ignore: public_member_api_docs + peah, + // ignore: public_member_api_docs + demai, + // ignore: public_member_api_docs + kilayim, + // ignore: public_member_api_docs + sheviis, + // ignore: public_member_api_docs + terumos, + // ignore: public_member_api_docs + maasros, + // ignore: public_member_api_docs + maaserSheni, + // ignore: public_member_api_docs + chalah, + // ignore: public_member_api_docs + orlah, + // ignore: public_member_api_docs + bikurim, + // ignore: public_member_api_docs + shabbos, + // ignore: public_member_api_docs + eruvin, + // ignore: public_member_api_docs + pesachim, + // ignore: public_member_api_docs + shekalim, + // ignore: public_member_api_docs + yoma, + // ignore: public_member_api_docs + sukkah, + // ignore: public_member_api_docs + beitzah, + // ignore: public_member_api_docs + roshHashanah, + // ignore: public_member_api_docs + taanis, + // ignore: public_member_api_docs + megillah, + // ignore: public_member_api_docs + moedKatan, + // ignore: public_member_api_docs + chagigah, + // ignore: public_member_api_docs + yevamos, + // ignore: public_member_api_docs + kesubos, + // ignore: public_member_api_docs + nedarim, + // ignore: public_member_api_docs + nazir, + // ignore: public_member_api_docs + sotah, + // ignore: public_member_api_docs + gitin, + // ignore: public_member_api_docs + kiddushin, + // ignore: public_member_api_docs + bavaKamma, + // ignore: public_member_api_docs + bavaMetzia, + // ignore: public_member_api_docs + bavaBasra, + // ignore: public_member_api_docs + sanhedrin, + // ignore: public_member_api_docs + makkos, + // ignore: public_member_api_docs + shevuos, + // ignore: public_member_api_docs + eduyos, + // ignore: public_member_api_docs + avodahZarah, + // ignore: public_member_api_docs + avos, + // ignore: public_member_api_docs + horiyos, + // ignore: public_member_api_docs + zevachim, + // ignore: public_member_api_docs + menachos, + // ignore: public_member_api_docs + chullin, + // ignore: public_member_api_docs + bechoros, + // ignore: public_member_api_docs + arachin, + // ignore: public_member_api_docs + temurah, + // ignore: public_member_api_docs + kerisos, + // ignore: public_member_api_docs + meilah, + // ignore: public_member_api_docs + tamid, + // ignore: public_member_api_docs + midos, + // ignore: public_member_api_docs + kinnim, + // ignore: public_member_api_docs + keilim, + // ignore: public_member_api_docs + ohalos, + // ignore: public_member_api_docs + negaim, + // ignore: public_member_api_docs + parah, + // ignore: public_member_api_docs + taharos, + // ignore: public_member_api_docs + mikvaos, + // ignore: public_member_api_docs + niddah, + // ignore: public_member_api_docs + machshirin, + // ignore: public_member_api_docs + zavim, + // ignore: public_member_api_docs + tevulYom, + // ignore: public_member_api_docs + yadayim, + // ignore: public_member_api_docs + uktzin; + +} + +// dart format on diff --git a/interop/packages/dart/lib/YearLengthTypeCode.g.dart b/interop/packages/dart/lib/YearLengthTypeCode.g.dart new file mode 100644 index 0000000..ae4b748 --- /dev/null +++ b/interop/packages/dart/lib/YearLengthTypeCode.g.dart @@ -0,0 +1,16 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +enum YearLengthTypeCode { + // ignore: public_member_api_docs + chaserim, + // ignore: public_member_api_docs + kesidran, + // ignore: public_member_api_docs + shelaimim; + +} + +// dart format on diff --git a/interop/packages/dart/lib/ZmanPresetId.g.dart b/interop/packages/dart/lib/ZmanPresetId.g.dart new file mode 100644 index 0000000..9c378a5 --- /dev/null +++ b/interop/packages/dart/lib/ZmanPresetId.g.dart @@ -0,0 +1,345 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +/// Stable identifier for a generated zman preset. +enum ZmanPresetId { + // ignore: public_member_api_docs + alos120Minutes, + // ignore: public_member_api_docs + alos120Zmanis, + // ignore: public_member_api_docs + alos16Point1Degrees, + // ignore: public_member_api_docs + alos18Degrees, + // ignore: public_member_api_docs + alos19Degrees, + // ignore: public_member_api_docs + alos19Point8Degrees, + // ignore: public_member_api_docs + alos26Degrees, + // ignore: public_member_api_docs + alos60Minutes, + // ignore: public_member_api_docs + alos72Minutes, + // ignore: public_member_api_docs + alos72Zmanis, + // ignore: public_member_api_docs + alos90Minutes, + // ignore: public_member_api_docs + alos90Zmanis, + // ignore: public_member_api_docs + alos96Minutes, + // ignore: public_member_api_docs + alos96Zmanis, + // ignore: public_member_api_docs + alosBaalHatanya, + // ignore: public_member_api_docs + bainHashmashosRt13Point24Degrees, + // ignore: public_member_api_docs + bainHashmashosRt13Point5MinutesBefore7Point083Degrees, + // ignore: public_member_api_docs + bainHashmashosRt2Stars, + // ignore: public_member_api_docs + bainHashmashosRt58Point5Minutes, + // ignore: public_member_api_docs + bainHashmashosYereim13Point5Minutes, + // ignore: public_member_api_docs + bainHashmashosYereim16Point875Minutes, + // ignore: public_member_api_docs + bainHashmashosYereim18Minutes, + // ignore: public_member_api_docs + bainHashmashosYereim2Point1Degrees, + // ignore: public_member_api_docs + bainHashmashosYereim2Point8Degrees, + // ignore: public_member_api_docs + bainHashmashosYereim3Point05Degrees, + // ignore: public_member_api_docs + beginAstronomicalTwilight, + // ignore: public_member_api_docs + beginCivilTwilight, + // ignore: public_member_api_docs + beginNauticalTwilight, + // ignore: public_member_api_docs + candleLighting, + // ignore: public_member_api_docs + chatzosHalayla, + // ignore: public_member_api_docs + chatzosHayom, + // ignore: public_member_api_docs + chatzosHayomAsHalfDay, + // ignore: public_member_api_docs + elevationAdjustedSunrise, + // ignore: public_member_api_docs + elevationAdjustedSunset, + // ignore: public_member_api_docs + endAstronomicalTwilight, + // ignore: public_member_api_docs + endCivilTwilight, + // ignore: public_member_api_docs + endNauticalTwilight, + // ignore: public_member_api_docs + fixedLocalChatzosHayom, + // ignore: public_member_api_docs + minchaGedola16Point1Degrees, + // ignore: public_member_api_docs + minchaGedola30Minutes, + // ignore: public_member_api_docs + minchaGedola72Minutes, + // ignore: public_member_api_docs + minchaGedolaAhavatShalom, + // ignore: public_member_api_docs + minchaGedolaAteretTorah, + // ignore: public_member_api_docs + minchaGedolaBaalHatanya, + // ignore: public_member_api_docs + minchaGedolaGra, + // ignore: public_member_api_docs + minchaGedolaGrafixedLocalChatzos30Minutes, + // ignore: public_member_api_docs + minchaGedolaGragreaterThan30, + // ignore: public_member_api_docs + minchaKetana16Point1Degrees, + // ignore: public_member_api_docs + minchaKetana72Minutes, + // ignore: public_member_api_docs + minchaKetanaAhavatShalom, + // ignore: public_member_api_docs + minchaKetanaAteretTorah, + // ignore: public_member_api_docs + minchaKetanaBaalHatanya, + // ignore: public_member_api_docs + minchaKetanaGra, + // ignore: public_member_api_docs + minchaKetanaGrafixedLocalChatzosToSunset, + // ignore: public_member_api_docs + misheyakir10Point2Degrees, + // ignore: public_member_api_docs + misheyakir11Degrees, + // ignore: public_member_api_docs + misheyakir11Point5Degrees, + // ignore: public_member_api_docs + misheyakir12Point85Degrees, + // ignore: public_member_api_docs + misheyakir7Point65Degrees, + // ignore: public_member_api_docs + misheyakir9Point5Degrees, + // ignore: public_member_api_docs + plagAhavatShalom, + // ignore: public_member_api_docs + plagAlos16Point1DegreesToTzaisGeonim7Point083Degrees, + // ignore: public_member_api_docs + plagAlosToSunset, + // ignore: public_member_api_docs + plagHamincha120Minutes, + // ignore: public_member_api_docs + plagHamincha120MinutesZmanis, + // ignore: public_member_api_docs + plagHamincha16Point1Degrees, + // ignore: public_member_api_docs + plagHamincha18Degrees, + // ignore: public_member_api_docs + plagHamincha19Point8Degrees, + // ignore: public_member_api_docs + plagHamincha26Degrees, + // ignore: public_member_api_docs + plagHamincha60Minutes, + // ignore: public_member_api_docs + plagHamincha72Minutes, + // ignore: public_member_api_docs + plagHamincha72MinutesZmanis, + // ignore: public_member_api_docs + plagHamincha90Minutes, + // ignore: public_member_api_docs + plagHamincha90MinutesZmanis, + // ignore: public_member_api_docs + plagHamincha96Minutes, + // ignore: public_member_api_docs + plagHamincha96MinutesZmanis, + // ignore: public_member_api_docs + plagHaminchaAteretTorah, + // ignore: public_member_api_docs + plagHaminchaBaalHatanya, + // ignore: public_member_api_docs + plagHaminchaGra, + // ignore: public_member_api_docs + plagHaminchaGrafixedLocalChatzosToSunset, + // ignore: public_member_api_docs + polarSunriseBenIshChai, + // ignore: public_member_api_docs + polarSunsetBenIshChai, + // ignore: public_member_api_docs + samuchLeMinchaKetana16Point1Degrees, + // ignore: public_member_api_docs + samuchLeMinchaKetana72Minutes, + // ignore: public_member_api_docs + samuchLeMinchaKetanaGra, + // ignore: public_member_api_docs + seaLevelSunrise, + // ignore: public_member_api_docs + seaLevelSunset, + // ignore: public_member_api_docs + sofZmanAchilasChametzBaalHatanya, + // ignore: public_member_api_docs + sofZmanAchilasChametzGra, + // ignore: public_member_api_docs + sofZmanAchilasChametzMga16Point1Degrees, + // ignore: public_member_api_docs + sofZmanAchilasChametzMga72Minutes, + // ignore: public_member_api_docs + sofZmanAchilasChametzMga72MinutesZmanis, + // ignore: public_member_api_docs + sofZmanBiurChametzBaalHatanya, + // ignore: public_member_api_docs + sofZmanBiurChametzGra, + // ignore: public_member_api_docs + sofZmanBiurChametzMga16Point1Degrees, + // ignore: public_member_api_docs + sofZmanBiurChametzMga72Minutes, + // ignore: public_member_api_docs + sofZmanBiurChametzMga72MinutesZmanis, + // ignore: public_member_api_docs + sofZmanKidushLevana15Days, + // ignore: public_member_api_docs + sofZmanKidushLevanaBetweenMoldos, + // ignore: public_member_api_docs + sofZmanShma3HoursBeforeChatzos, + // ignore: public_member_api_docs + sofZmanShmaAlos16Point1DegreesToTzaisGeonim7Point083Degrees, + // ignore: public_member_api_docs + sofZmanShmaAlos16Point1ToSunset, + // ignore: public_member_api_docs + sofZmanShmaAteretTorah, + // ignore: public_member_api_docs + sofZmanShmaBaalHatanya, + // ignore: public_member_api_docs + sofZmanShmaGra, + // ignore: public_member_api_docs + sofZmanShmaGrasunriseToFixedLocalChatzos, + // ignore: public_member_api_docs + sofZmanShmaMga120Minutes, + // ignore: public_member_api_docs + sofZmanShmaMga16Point1Degrees, + // ignore: public_member_api_docs + sofZmanShmaMga16Point1DegreesToFixedLocalChatzos, + // ignore: public_member_api_docs + sofZmanShmaMga18Degrees, + // ignore: public_member_api_docs + sofZmanShmaMga18DegreesToFixedLocalChatzos, + // ignore: public_member_api_docs + sofZmanShmaMga19Point8Degrees, + // ignore: public_member_api_docs + sofZmanShmaMga72Minutes, + // ignore: public_member_api_docs + sofZmanShmaMga72MinutesToFixedLocalChatzos, + // ignore: public_member_api_docs + sofZmanShmaMga72MinutesZmanis, + // ignore: public_member_api_docs + sofZmanShmaMga90Minutes, + // ignore: public_member_api_docs + sofZmanShmaMga90MinutesToFixedLocalChatzos, + // ignore: public_member_api_docs + sofZmanShmaMga90MinutesZmanis, + // ignore: public_member_api_docs + sofZmanShmaMga96Minutes, + // ignore: public_member_api_docs + sofZmanShmaMga96MinutesZmanis, + // ignore: public_member_api_docs + sofZmanTfila2HoursBeforeChatzos, + // ignore: public_member_api_docs + sofZmanTfilaAteretTorah, + // ignore: public_member_api_docs + sofZmanTfilaBaalHatanya, + // ignore: public_member_api_docs + sofZmanTfilaGra, + // ignore: public_member_api_docs + sofZmanTfilaGrasunriseToFixedLocalChatzos, + // ignore: public_member_api_docs + sofZmanTfilaMga120Minutes, + // ignore: public_member_api_docs + sofZmanTfilaMga16Point1Degrees, + // ignore: public_member_api_docs + sofZmanTfilaMga18Degrees, + // ignore: public_member_api_docs + sofZmanTfilaMga19Point8Degrees, + // ignore: public_member_api_docs + sofZmanTfilaMga72Minutes, + // ignore: public_member_api_docs + sofZmanTfilaMga72MinutesZmanis, + // ignore: public_member_api_docs + sofZmanTfilaMga90Minutes, + // ignore: public_member_api_docs + sofZmanTfilaMga90MinutesZmanis, + // ignore: public_member_api_docs + sofZmanTfilaMga96Minutes, + // ignore: public_member_api_docs + sofZmanTfilaMga96MinutesZmanis, + // ignore: public_member_api_docs + solarMidnight, + // ignore: public_member_api_docs + sunTransit, + // ignore: public_member_api_docs + tchilasZmanKidushLevana3Days, + // ignore: public_member_api_docs + tchilasZmanKidushLevana7Days, + // ignore: public_member_api_docs + tzais120Minutes, + // ignore: public_member_api_docs + tzais120Zmanis, + // ignore: public_member_api_docs + tzais16Point1Degrees, + // ignore: public_member_api_docs + tzais18Degrees, + // ignore: public_member_api_docs + tzais19Point8Degrees, + // ignore: public_member_api_docs + tzais26Degrees, + // ignore: public_member_api_docs + tzais50Minutes, + // ignore: public_member_api_docs + tzais60Minutes, + // ignore: public_member_api_docs + tzais72Minutes, + // ignore: public_member_api_docs + tzais72Zmanis, + // ignore: public_member_api_docs + tzais90Minutes, + // ignore: public_member_api_docs + tzais90Zmanis, + // ignore: public_member_api_docs + tzais96Minutes, + // ignore: public_member_api_docs + tzais96Zmanis, + // ignore: public_member_api_docs + tzaisAteretTorah, + // ignore: public_member_api_docs + tzaisBaalHatanya, + // ignore: public_member_api_docs + tzaisGeonim3Point7Degrees, + // ignore: public_member_api_docs + tzaisGeonim3Point8Degrees, + // ignore: public_member_api_docs + tzaisGeonim4Point42Degrees, + // ignore: public_member_api_docs + tzaisGeonim4Point66Degrees, + // ignore: public_member_api_docs + tzaisGeonim4Point8Degrees, + // ignore: public_member_api_docs + tzaisGeonim5Point95Degrees, + // ignore: public_member_api_docs + tzaisGeonim6Point45Degrees, + // ignore: public_member_api_docs + tzaisGeonim7Point083Degrees, + // ignore: public_member_api_docs + tzaisGeonim7Point67Degrees, + // ignore: public_member_api_docs + tzaisGeonim8Point5Degrees, + // ignore: public_member_api_docs + tzaisGeonim9Point3Degrees, + // ignore: public_member_api_docs + tzaisGeonim9Point75Degrees; + +} + +// dart format on diff --git a/interop/packages/dart/lib/ZmanPresets.g.dart b/interop/packages/dart/lib/ZmanPresets.g.dart new file mode 100644 index 0000000..a12dec3 --- /dev/null +++ b/interop/packages/dart/lib/ZmanPresets.g.dart @@ -0,0 +1,84 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +/// Dart entry point: construct once and call instance methods. +final class ZmanPresets implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + ZmanPresets._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + @_DiplomatFfiUse('ZmanPresets_destroy') + static final _finalizer = ffi.NativeFinalizer(ffi.Native.addressOf(_ZmanPresets_destroy)); + + factory ZmanPresets() { + final result = _ZmanPresets_new(); + return ZmanPresets._fromFfi(result, []); + } + + int presetCount() { + final result = _ZmanPresets_preset_count(_ffi); + return result; + } + + bool presetName(ZmanPresetId preset) { + final result = _ZmanPresets_preset_name(_ffi, preset.index); + return result; + } + + bool presetDeprecated(ZmanPresetId preset) { + final result = _ZmanPresets_preset_deprecated(_ffi, preset.index); + return result; + } + + bool presetMethodName(ZmanPresetId preset) { + final result = _ZmanPresets_preset_method_name(_ffi, preset.index); + return result; + } + +} + +@_DiplomatFfiUse('ZmanPresets_destroy') +@ffi.Native)>(isLeaf: true, symbol: 'ZmanPresets_destroy') +// ignore: non_constant_identifier_names +external void _ZmanPresets_destroy(ffi.Pointer self); + +@_DiplomatFfiUse('ZmanPresets_new') +@ffi.Native Function()>(isLeaf: true, symbol: 'ZmanPresets_new') +// ignore: non_constant_identifier_names +external ffi.Pointer _ZmanPresets_new(); + +@_DiplomatFfiUse('ZmanPresets_preset_count') +@ffi.Native)>(isLeaf: true, symbol: 'ZmanPresets_preset_count') +// ignore: non_constant_identifier_names +external int _ZmanPresets_preset_count(ffi.Pointer self); + +@_DiplomatFfiUse('ZmanPresets_preset_name') +@ffi.Native, ffi.Int32)>(isLeaf: true, symbol: 'ZmanPresets_preset_name') +// ignore: non_constant_identifier_names +external bool _ZmanPresets_preset_name(ffi.Pointer self, int preset); + +@_DiplomatFfiUse('ZmanPresets_preset_deprecated') +@ffi.Native, ffi.Int32)>(isLeaf: true, symbol: 'ZmanPresets_preset_deprecated') +// ignore: non_constant_identifier_names +external bool _ZmanPresets_preset_deprecated(ffi.Pointer self, int preset); + +@_DiplomatFfiUse('ZmanPresets_preset_method_name') +@ffi.Native, ffi.Int32)>(isLeaf: true, symbol: 'ZmanPresets_preset_method_name') +// ignore: non_constant_identifier_names +external bool _ZmanPresets_preset_method_name(ffi.Pointer self, int preset); + +// dart format on diff --git a/interop/packages/dart/lib/ZmanimErrorCode.g.dart b/interop/packages/dart/lib/ZmanimErrorCode.g.dart new file mode 100644 index 0000000..19bcb60 --- /dev/null +++ b/interop/packages/dart/lib/ZmanimErrorCode.g.dart @@ -0,0 +1,30 @@ +// generated by diplomat-tool +// dart format off + +part of 'lib.g.dart'; + +enum ZmanimErrorCode { + // ignore: public_member_api_docs + invalidLatitude, + // ignore: public_member_api_docs + invalidLongitude, + // ignore: public_member_api_docs + invalidElevation, + // ignore: public_member_api_docs + timeZoneRequired, + // ignore: public_member_api_docs + calculationError, + // ignore: public_member_api_docs + allDay, + // ignore: public_member_api_docs + allNight, + // ignore: public_member_api_docs + timeConversionError, + // ignore: public_member_api_docs + invalidForDate, + // ignore: public_member_api_docs + invalidHours; + +} + +// dart format on diff --git a/interop/packages/dart/lib/kosher_rust_for_dart.dart b/interop/packages/dart/lib/kosher_rust_for_dart.dart new file mode 100644 index 0000000..fcccdb2 --- /dev/null +++ b/interop/packages/dart/lib/kosher_rust_for_dart.dart @@ -0,0 +1 @@ +export 'lib.g.dart'; diff --git a/interop/packages/dart/lib/lib.g.dart b/interop/packages/dart/lib/lib.g.dart new file mode 100644 index 0000000..7a0d395 --- /dev/null +++ b/interop/packages/dart/lib/lib.g.dart @@ -0,0 +1,523 @@ +// generated by diplomat-tool +// dart format off + +import 'dart:convert'; +// ignore: unused_import +import 'dart:core' as core; +// ignore: unused_shown_name +import 'dart:core' show Object, String, bool, double, int, override; +import 'dart:ffi' as ffi; +// ignore: unused_import +import 'dart:typed_data'; +import 'package:ffi/ffi.dart' as ffi2 show Arena, calloc; +import 'package:meta/meta.dart' as meta; +part 'AmudResult.g.dart'; +part 'CalculatorConfig.g.dart'; +part 'Calendar.g.dart'; +part 'CivilDate.g.dart'; +part 'DafResult.g.dart'; +part 'FfiLocation.g.dart'; +part 'FfiZmanimCalculator.g.dart'; +part 'HebrewDate.g.dart'; +part 'HolidayCode.g.dart'; +part 'HolidayEntry.g.dart'; +part 'HolidayList.g.dart'; +part 'Limudim.g.dart'; +part 'MishnaResult.g.dart'; +part 'MishnasResult.g.dart'; +part 'ParshaCode.g.dart'; +part 'PirkeiAvosResult.g.dart'; +part 'SideCode.g.dart'; +part 'TehillimResult.g.dart'; +part 'TractateCode.g.dart'; +part 'YearLengthTypeCode.g.dart'; +part 'ZmanPresetId.g.dart'; +part 'ZmanPresets.g.dart'; +part 'ZmanimErrorCode.g.dart'; + +// ignore: experimental_member_use +@meta.RecordUse() +final class _DiplomatFfiUse { + final String symbol; + + // ignore: experimental_member_use + const _DiplomatFfiUse(@meta.mustBeConst this.symbol); +} + +/// A [Rune] is a Unicode code point, such as `a`, or `💡`. +/// +/// The recommended way to obtain a [Rune] is to create it from a +/// [String], which is conceptually a sequence of [Rune]s. For +/// example, `'a'.runes.first` is equal to the [Rune] `a`. +/// +/// Dart does not have a character/rune literal (https://github.com/dart-lang/language/issues/886), +/// so integer literals need to be used. For example the Unicode code point +/// U+1F4A1, `💡`, can be represented by `0x1F4A1`. +/// +/// A [String] can be constructed from a [Rune] using (the [confusingly named]( +/// https://github.com/dart-lang/sdk/issues/56304)) [String.fromCharCode]. +typedef Rune = int; + +// ignore: unused_element +final _callocFree = core.Finalizer(ffi2.calloc.free); + +// ignore: unused_element +final _nopFree = core.Finalizer((nothing) => {}); + +// ignore: unused_element +final _rustFree = core.Finalizer( + (({ffi.Pointer pointer, int bytes, int align}) record) => + _diplomat_free(record.pointer, record.bytes, record.align), +); + +// ignore: unused_element +final class _RustAlloc implements ffi.Allocator { + @override + ffi.Pointer allocate( + int byteCount, { + int? alignment, + }) { + return _diplomat_alloc(byteCount, alignment ?? 1).cast(); + } + + @override + void free(ffi.Pointer pointer) { + throw 'Internal error: should not deallocate in Rust memory'; + } +} + +@_DiplomatFfiUse('diplomat_alloc') +@ffi.Native Function(ffi.Size, ffi.Size)>( + symbol: 'diplomat_alloc', + isLeaf: true, +) +// ignore: non_constant_identifier_names +external ffi.Pointer _diplomat_alloc(int len, int align); + +@_DiplomatFfiUse('diplomat_free') +@ffi.Native, ffi.Size, ffi.Size)>( + symbol: 'diplomat_free', + isLeaf: true, +) +// ignore: non_constant_identifier_names +external int _diplomat_free(ffi.Pointer ptr, int len, int align); + +// ignore: unused_element +class _FinalizedArena { + final ffi2.Arena arena; + static final core.Finalizer _finalizer = core.Finalizer( + (arena) => arena.releaseAll(), + ); + + // ignore: unused_element + _FinalizedArena() : arena = ffi2.Arena() { + _finalizer.attach(this, arena); + } + + // ignore: unused_element + _FinalizedArena.withLifetime(core.List> lifetimeAppendArray) + : arena = ffi2.Arena() { + _finalizer.attach(this, arena); + for (final edge in lifetimeAppendArray) { + edge.add(this); + } + } +} + +final class _ResultAmudResultFfiVoidUnion extends ffi.Union { + external _AmudResultFfi ok; + +} + +final class _ResultAmudResultFfiVoid extends ffi.Struct { + external _ResultAmudResultFfiVoidUnion union; + + @ffi.Bool() + external bool isOk; + + // ignore: unused_element + factory _ResultAmudResultFfiVoid.ok(_AmudResultFfi val) { + final struct = ffi.Struct.create<_ResultAmudResultFfiVoid>(); + struct.isOk = true; + struct.union.ok = val; + return struct; + } + // ignore: unused_element + factory _ResultAmudResultFfiVoid.err() { + final struct = ffi.Struct.create<_ResultAmudResultFfiVoid>(); + struct.isOk = false; + return struct; + } +} + +final class _ResultBoolVoidUnion extends ffi.Union { + @ffi.Bool() + external bool ok; + +} + +final class _ResultBoolVoid extends ffi.Struct { + external _ResultBoolVoidUnion union; + + @ffi.Bool() + external bool isOk; + + // ignore: unused_element + factory _ResultBoolVoid.ok(bool val) { + final struct = ffi.Struct.create<_ResultBoolVoid>(); + struct.isOk = true; + struct.union.ok = val; + return struct; + } + // ignore: unused_element + factory _ResultBoolVoid.err() { + final struct = ffi.Struct.create<_ResultBoolVoid>(); + struct.isOk = false; + return struct; + } +} + +final class _ResultCivilDateFfiVoidUnion extends ffi.Union { + external _CivilDateFfi ok; + +} + +final class _ResultCivilDateFfiVoid extends ffi.Struct { + external _ResultCivilDateFfiVoidUnion union; + + @ffi.Bool() + external bool isOk; + + // ignore: unused_element + factory _ResultCivilDateFfiVoid.ok(_CivilDateFfi val) { + final struct = ffi.Struct.create<_ResultCivilDateFfiVoid>(); + struct.isOk = true; + struct.union.ok = val; + return struct; + } + // ignore: unused_element + factory _ResultCivilDateFfiVoid.err() { + final struct = ffi.Struct.create<_ResultCivilDateFfiVoid>(); + struct.isOk = false; + return struct; + } +} + +final class _ResultDafResultFfiVoidUnion extends ffi.Union { + external _DafResultFfi ok; + +} + +final class _ResultDafResultFfiVoid extends ffi.Struct { + external _ResultDafResultFfiVoidUnion union; + + @ffi.Bool() + external bool isOk; + + // ignore: unused_element + factory _ResultDafResultFfiVoid.ok(_DafResultFfi val) { + final struct = ffi.Struct.create<_ResultDafResultFfiVoid>(); + struct.isOk = true; + struct.union.ok = val; + return struct; + } + // ignore: unused_element + factory _ResultDafResultFfiVoid.err() { + final struct = ffi.Struct.create<_ResultDafResultFfiVoid>(); + struct.isOk = false; + return struct; + } +} + +final class _ResultHebrewDateFfiVoidUnion extends ffi.Union { + external _HebrewDateFfi ok; + +} + +final class _ResultHebrewDateFfiVoid extends ffi.Struct { + external _ResultHebrewDateFfiVoidUnion union; + + @ffi.Bool() + external bool isOk; + + // ignore: unused_element + factory _ResultHebrewDateFfiVoid.ok(_HebrewDateFfi val) { + final struct = ffi.Struct.create<_ResultHebrewDateFfiVoid>(); + struct.isOk = true; + struct.union.ok = val; + return struct; + } + // ignore: unused_element + factory _ResultHebrewDateFfiVoid.err() { + final struct = ffi.Struct.create<_ResultHebrewDateFfiVoid>(); + struct.isOk = false; + return struct; + } +} + +final class _ResultHolidayEntryFfiVoidUnion extends ffi.Union { + external _HolidayEntryFfi ok; + +} + +final class _ResultHolidayEntryFfiVoid extends ffi.Struct { + external _ResultHolidayEntryFfiVoidUnion union; + + @ffi.Bool() + external bool isOk; + + // ignore: unused_element + factory _ResultHolidayEntryFfiVoid.ok(_HolidayEntryFfi val) { + final struct = ffi.Struct.create<_ResultHolidayEntryFfiVoid>(); + struct.isOk = true; + struct.union.ok = val; + return struct; + } + // ignore: unused_element + factory _ResultHolidayEntryFfiVoid.err() { + final struct = ffi.Struct.create<_ResultHolidayEntryFfiVoid>(); + struct.isOk = false; + return struct; + } +} + +final class _ResultInt32VoidUnion extends ffi.Union { + @ffi.Int32() + external int ok; + +} + +final class _ResultInt32Void extends ffi.Struct { + external _ResultInt32VoidUnion union; + + @ffi.Bool() + external bool isOk; + + // ignore: unused_element + factory _ResultInt32Void.ok(int val) { + final struct = ffi.Struct.create<_ResultInt32Void>(); + struct.isOk = true; + struct.union.ok = val; + return struct; + } + // ignore: unused_element + factory _ResultInt32Void.err() { + final struct = ffi.Struct.create<_ResultInt32Void>(); + struct.isOk = false; + return struct; + } +} + +final class _ResultInt64Int32Union extends ffi.Union { + @ffi.Int64() + external int ok; + + @ffi.Int32() + external int err; +} + +final class _ResultInt64Int32 extends ffi.Struct { + external _ResultInt64Int32Union union; + + @ffi.Bool() + external bool isOk; + + // ignore: unused_element + factory _ResultInt64Int32.ok(int val) { + final struct = ffi.Struct.create<_ResultInt64Int32>(); + struct.isOk = true; + struct.union.ok = val; + return struct; + } + // ignore: unused_element + factory _ResultInt64Int32.err(int val) { + final struct = ffi.Struct.create<_ResultInt64Int32>(); + struct.isOk = false; + struct.union.err = val; + return struct; + } +} + +final class _ResultMishnasResultFfiVoidUnion extends ffi.Union { + external _MishnasResultFfi ok; + +} + +final class _ResultMishnasResultFfiVoid extends ffi.Struct { + external _ResultMishnasResultFfiVoidUnion union; + + @ffi.Bool() + external bool isOk; + + // ignore: unused_element + factory _ResultMishnasResultFfiVoid.ok(_MishnasResultFfi val) { + final struct = ffi.Struct.create<_ResultMishnasResultFfiVoid>(); + struct.isOk = true; + struct.union.ok = val; + return struct; + } + // ignore: unused_element + factory _ResultMishnasResultFfiVoid.err() { + final struct = ffi.Struct.create<_ResultMishnasResultFfiVoid>(); + struct.isOk = false; + return struct; + } +} + +final class _ResultOpaqueInt32Union extends ffi.Union { + external ffi.Pointer ok; + + @ffi.Int32() + external int err; +} + +final class _ResultOpaqueInt32 extends ffi.Struct { + external _ResultOpaqueInt32Union union; + + @ffi.Bool() + external bool isOk; + + // ignore: unused_element + factory _ResultOpaqueInt32.ok(ffi.Pointer val) { + final struct = ffi.Struct.create<_ResultOpaqueInt32>(); + struct.isOk = true; + struct.union.ok = val; + return struct; + } + // ignore: unused_element + factory _ResultOpaqueInt32.err(int val) { + final struct = ffi.Struct.create<_ResultOpaqueInt32>(); + struct.isOk = false; + struct.union.err = val; + return struct; + } +} + +final class _ResultPirkeiAvosResultFfiVoidUnion extends ffi.Union { + external _PirkeiAvosResultFfi ok; + +} + +final class _ResultPirkeiAvosResultFfiVoid extends ffi.Struct { + external _ResultPirkeiAvosResultFfiVoidUnion union; + + @ffi.Bool() + external bool isOk; + + // ignore: unused_element + factory _ResultPirkeiAvosResultFfiVoid.ok(_PirkeiAvosResultFfi val) { + final struct = ffi.Struct.create<_ResultPirkeiAvosResultFfiVoid>(); + struct.isOk = true; + struct.union.ok = val; + return struct; + } + // ignore: unused_element + factory _ResultPirkeiAvosResultFfiVoid.err() { + final struct = ffi.Struct.create<_ResultPirkeiAvosResultFfiVoid>(); + struct.isOk = false; + return struct; + } +} + +final class _ResultTehillimResultFfiVoidUnion extends ffi.Union { + external _TehillimResultFfi ok; + +} + +final class _ResultTehillimResultFfiVoid extends ffi.Struct { + external _ResultTehillimResultFfiVoidUnion union; + + @ffi.Bool() + external bool isOk; + + // ignore: unused_element + factory _ResultTehillimResultFfiVoid.ok(_TehillimResultFfi val) { + final struct = ffi.Struct.create<_ResultTehillimResultFfiVoid>(); + struct.isOk = true; + struct.union.ok = val; + return struct; + } + // ignore: unused_element + factory _ResultTehillimResultFfiVoid.err() { + final struct = ffi.Struct.create<_ResultTehillimResultFfiVoid>(); + struct.isOk = false; + return struct; + } +} + +final class _ResultUint8VoidUnion extends ffi.Union { + @ffi.Uint8() + external int ok; + +} + +final class _ResultUint8Void extends ffi.Struct { + external _ResultUint8VoidUnion union; + + @ffi.Bool() + external bool isOk; + + // ignore: unused_element + factory _ResultUint8Void.ok(int val) { + final struct = ffi.Struct.create<_ResultUint8Void>(); + struct.isOk = true; + struct.union.ok = val; + return struct; + } + // ignore: unused_element + factory _ResultUint8Void.err() { + final struct = ffi.Struct.create<_ResultUint8Void>(); + struct.isOk = false; + return struct; + } +} + +final class _SliceUtf8 extends ffi.Struct { + external ffi.Pointer _data; + + @ffi.Size() + external int _length; + + // This is expensive + @override + bool operator ==(Object other) { + if (other is! _SliceUtf8 || other._length != _length) { + return false; + } + + for (var i = 0; i < _length; i++) { + if (other._data[i] != _data[i]) { + return false; + } + } + return true; + } + + // This is cheap + @override + int get hashCode => _length.hashCode; + + // ignore: unused_element + String _toDart(core.List lifetimeEdges, {bool isStatic = false}) { + final r = const Utf8Decoder().convert(_data.asTypedList(_length)); + if (lifetimeEdges.isEmpty && !isStatic) { + _diplomat_free(_data.cast(), _length, 1); + } else { + // Lifetime edges will be cleaned up + } + return r; + } +} + +extension on String { + // ignore: unused_element + _SliceUtf8 _utf8AllocIn(ffi.Allocator alloc) { + final slice = ffi.Struct.create<_SliceUtf8>(); + final encoded = const Utf8Encoder().convert(this); + slice._data = alloc(encoded.length)..asTypedList(encoded.length).setRange(0, encoded.length, encoded); + slice._length = encoded.length; + return slice; + } +} + +// dart format on diff --git a/interop/packages/dart/pubspec.yaml b/interop/packages/dart/pubspec.yaml new file mode 100644 index 0000000..61b1afa --- /dev/null +++ b/interop/packages/dart/pubspec.yaml @@ -0,0 +1,16 @@ +name: kosher_rust_for_dart +description: Kosher Rust for Dart +version: 1.0.0 + +environment: + sdk: ^3.12.0 + +dependencies: + ffi: ^2.2.0 + meta: ^1.18.0 + +dev_dependencies: + code_assets: ^1.2.1 + hooks: ^2.0.2 + lints: ^6.0.0 + test: ^1.25.6 diff --git a/interop/packages/dart/test/smoke_test.dart b/interop/packages/dart/test/smoke_test.dart new file mode 100644 index 0000000..9f62d53 --- /dev/null +++ b/interop/packages/dart/test/smoke_test.dart @@ -0,0 +1,37 @@ +import 'package:kosher_rust_for_dart/kosher_rust_for_dart.dart'; +import 'package:test/test.dart'; + +void main() { + group('kosher_rust_for_dart smoke', () { + test('gregorian/hebrew round trip via Calendar', () { + final calendar = Calendar(); + final civil = CivilDate(year: 2024, month: 1, day: 20); + + final hebrew = calendar.gregorianToHebrew(civil); + expect(hebrew, isNotNull); + expect(hebrew!.year, 5784); + expect(hebrew.month, 5); + expect(hebrew.day, 10); + + final back = calendar.hebrewToGregorian(hebrew); + expect(back, isNotNull); + expect(back!.year, civil.year); + expect(back.month, civil.month); + expect(back.day, civil.day); + }); + + test('daf yomi bavli via Limudim', () { + final limudim = Limudim(); + final daf = limudim.dafYomiBavli(2017, 12, 28); + + expect(daf, isNotNull); + expect(daf!.tractate, TractateCode.shevuos); + expect(daf.page, 30); + }); + + test('preset count via ZmanPresets', () { + final presets = ZmanPresets(); + expect(presets.presetCount(), 167); + }); + }); +} diff --git a/interop/packages/typescript/.gitignore b/interop/packages/typescript/.gitignore new file mode 100644 index 0000000..1081810 --- /dev/null +++ b/interop/packages/typescript/.gitignore @@ -0,0 +1,4 @@ +node_modules/ + +# Generated by `npm run generate` (diplomat-tool js) +# /lib/ diff --git a/interop/packages/typescript/diplomat.config.mjs b/interop/packages/typescript/diplomat.config.mjs new file mode 100644 index 0000000..7635711 --- /dev/null +++ b/interop/packages/typescript/diplomat.config.mjs @@ -0,0 +1,14 @@ +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const packageRoot = path.dirname(fileURLToPath(import.meta.url)); +const profile = process.env.CARGO_PROFILE ?? "debug"; + +export default { + wasm_path: path.join( + packageRoot, + "../../../target/wasm32-unknown-unknown", + profile, + "interop.wasm", + ), +}; diff --git a/interop/packages/typescript/lib/AmudResult.d.ts b/interop/packages/typescript/lib/AmudResult.d.ts new file mode 100644 index 0000000..81dbbfc --- /dev/null +++ b/interop/packages/typescript/lib/AmudResult.d.ts @@ -0,0 +1,30 @@ +// generated by diplomat-tool +import type { SideCode } from "./SideCode" +import type { TractateCode } from "./TractateCode" +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + +export type AmudResult_obj = { + tractate: TractateCode; + page: number; + side: SideCode; +}; + + + +export class AmudResult { + get tractate(): TractateCode; + set tractate(value: TractateCode); + get page(): number; + set page(value: number); + get side(): SideCode; + set side(value: SideCode); + /** @internal */ + static fromFields(structObj : AmudResult_obj) : AmudResult; + + /** + * Create `AmudResult` from an object that contains all of `AmudResult`s fields. + * Optional fields do not need to be included in the provided object. + */ + constructor(structObj: AmudResult_obj); + +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/AmudResult.mjs b/interop/packages/typescript/lib/AmudResult.mjs new file mode 100644 index 0000000..7f22c88 --- /dev/null +++ b/interop/packages/typescript/lib/AmudResult.mjs @@ -0,0 +1,131 @@ +// generated by diplomat-tool +import { SideCode } from "./SideCode.mjs" +import { TractateCode } from "./TractateCode.mjs" +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +export class AmudResult { + #tractate; + get tractate() { + return this.#tractate; + } + set tractate(value){ + this.#tractate = value; + } + #page; + get page() { + return this.#page; + } + set page(value){ + this.#page = value; + } + #side; + get side() { + return this.#side; + } + set side(value){ + this.#side = value; + } + /** @internal */ + static fromFields(structObj) { + return new AmudResult(structObj); + } + + #internalConstructor(structObj) { + if (typeof structObj !== "object") { + throw new Error("AmudResult's constructor takes an object of AmudResult's fields."); + } + + if ("tractate" in structObj) { + this.#tractate = structObj.tractate; + } else { + throw new Error("Missing required field tractate."); + } + + if ("page" in structObj) { + this.#page = structObj.page; + } else { + throw new Error("Missing required field page."); + } + + if ("side" in structObj) { + this.#side = structObj.side; + } else { + throw new Error("Missing required field side."); + } + + return this; + } + + // Return this struct in FFI function friendly format. + // Returns an array that can be expanded with spread syntax (...) + _intoFFI( + dst, + functionCleanupArena, + appendArrayMap + ) { + + this._writeToArrayBuffer(wasm.memory.buffer, dst, functionCleanupArena, appendArrayMap); + + return dst; + } + + static get _sizeBytes() { + return 12; + } + + /// Currently unused, we may want to use later on though: + static get _sizeAlign() { + return 4; + } + + static _fromSuppliedValue(internalConstructor, obj) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("_fromSuppliedValue cannot be called externally."); + } + + if (obj instanceof AmudResult) { + return obj; + } + + return AmudResult.fromFields(obj); + } + + _writeToArrayBuffer( + arrayBuffer, + offset, + functionCleanupArena, + appendArrayMap + ) { + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#tractate.ffiValue, Int32Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 4, this.#page, Uint16Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 8, this.#side.ffiValue, Int32Array); + } + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + static _fromFFI(internalConstructor, ptr) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("AmudResult._fromFFI is not meant to be called externally. Please use the default constructor."); + } + let structObj = {}; + const tractateDeref = diplomatRuntime.enumDiscriminant(wasm, ptr); + structObj.tractate = new TractateCode(diplomatRuntime.internalConstructor, tractateDeref); + const pageDeref = (new Uint16Array(wasm.memory.buffer, ptr + 4, 1))[0]; + structObj.page = pageDeref; + const sideDeref = diplomatRuntime.enumDiscriminant(wasm, ptr + 8); + structObj.side = new SideCode(diplomatRuntime.internalConstructor, sideDeref); + + return new AmudResult(structObj); + } + + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/CalculatorConfig.d.ts b/interop/packages/typescript/lib/CalculatorConfig.d.ts new file mode 100644 index 0000000..881b60b --- /dev/null +++ b/interop/packages/typescript/lib/CalculatorConfig.d.ts @@ -0,0 +1,37 @@ +// generated by diplomat-tool +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + +export type CalculatorConfig_obj = { + candleLightingOffsetMinutes: number; + useAstronomicalChatzosForOtherZmanim: boolean; + useElevation: boolean; + ateretTorahSunsetOffsetMinutes: number; + useAstronomicalChatzos: boolean; +}; + + + +/** + * Calculator configuration (durations in minutes). + */ +export class CalculatorConfig { + get candleLightingOffsetMinutes(): number; + set candleLightingOffsetMinutes(value: number); + get useAstronomicalChatzosForOtherZmanim(): boolean; + set useAstronomicalChatzosForOtherZmanim(value: boolean); + get useElevation(): boolean; + set useElevation(value: boolean); + get ateretTorahSunsetOffsetMinutes(): number; + set ateretTorahSunsetOffsetMinutes(value: number); + get useAstronomicalChatzos(): boolean; + set useAstronomicalChatzos(value: boolean); + /** @internal */ + static fromFields(structObj : CalculatorConfig_obj) : CalculatorConfig; + + /** + * Create `CalculatorConfig` from an object that contains all of `CalculatorConfig`s fields. + * Optional fields do not need to be included in the provided object. + */ + constructor(structObj: CalculatorConfig_obj); + +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/CalculatorConfig.mjs b/interop/packages/typescript/lib/CalculatorConfig.mjs new file mode 100644 index 0000000..71e08bf --- /dev/null +++ b/interop/packages/typescript/lib/CalculatorConfig.mjs @@ -0,0 +1,164 @@ +// generated by diplomat-tool +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +/** + * Calculator configuration (durations in minutes). + */ +export class CalculatorConfig { + #candleLightingOffsetMinutes; + get candleLightingOffsetMinutes() { + return this.#candleLightingOffsetMinutes; + } + set candleLightingOffsetMinutes(value){ + this.#candleLightingOffsetMinutes = value; + } + #useAstronomicalChatzosForOtherZmanim; + get useAstronomicalChatzosForOtherZmanim() { + return this.#useAstronomicalChatzosForOtherZmanim; + } + set useAstronomicalChatzosForOtherZmanim(value){ + this.#useAstronomicalChatzosForOtherZmanim = value; + } + #useElevation; + get useElevation() { + return this.#useElevation; + } + set useElevation(value){ + this.#useElevation = value; + } + #ateretTorahSunsetOffsetMinutes; + get ateretTorahSunsetOffsetMinutes() { + return this.#ateretTorahSunsetOffsetMinutes; + } + set ateretTorahSunsetOffsetMinutes(value){ + this.#ateretTorahSunsetOffsetMinutes = value; + } + #useAstronomicalChatzos; + get useAstronomicalChatzos() { + return this.#useAstronomicalChatzos; + } + set useAstronomicalChatzos(value){ + this.#useAstronomicalChatzos = value; + } + /** @internal */ + static fromFields(structObj) { + return new CalculatorConfig(structObj); + } + + #internalConstructor(structObj) { + if (typeof structObj !== "object") { + throw new Error("CalculatorConfig's constructor takes an object of CalculatorConfig's fields."); + } + + if ("candleLightingOffsetMinutes" in structObj) { + this.#candleLightingOffsetMinutes = structObj.candleLightingOffsetMinutes; + } else { + throw new Error("Missing required field candleLightingOffsetMinutes."); + } + + if ("useAstronomicalChatzosForOtherZmanim" in structObj) { + this.#useAstronomicalChatzosForOtherZmanim = structObj.useAstronomicalChatzosForOtherZmanim; + } else { + throw new Error("Missing required field useAstronomicalChatzosForOtherZmanim."); + } + + if ("useElevation" in structObj) { + this.#useElevation = structObj.useElevation; + } else { + throw new Error("Missing required field useElevation."); + } + + if ("ateretTorahSunsetOffsetMinutes" in structObj) { + this.#ateretTorahSunsetOffsetMinutes = structObj.ateretTorahSunsetOffsetMinutes; + } else { + throw new Error("Missing required field ateretTorahSunsetOffsetMinutes."); + } + + if ("useAstronomicalChatzos" in structObj) { + this.#useAstronomicalChatzos = structObj.useAstronomicalChatzos; + } else { + throw new Error("Missing required field useAstronomicalChatzos."); + } + + return this; + } + + // Return this struct in FFI function friendly format. + // Returns an array that can be expanded with spread syntax (...) + _intoFFI( + dst, + functionCleanupArena, + appendArrayMap + ) { + + this._writeToArrayBuffer(wasm.memory.buffer, dst, functionCleanupArena, appendArrayMap); + + return dst; + } + + static get _sizeBytes() { + return 16; + } + + /// Currently unused, we may want to use later on though: + static get _sizeAlign() { + return 4; + } + + static _fromSuppliedValue(internalConstructor, obj) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("_fromSuppliedValue cannot be called externally."); + } + + if (obj instanceof CalculatorConfig) { + return obj; + } + + return CalculatorConfig.fromFields(obj); + } + + _writeToArrayBuffer( + arrayBuffer, + offset, + functionCleanupArena, + appendArrayMap + ) { + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#candleLightingOffsetMinutes, Int32Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 4, this.#useAstronomicalChatzosForOtherZmanim, Uint8Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 5, this.#useElevation, Uint8Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 8, this.#ateretTorahSunsetOffsetMinutes, Int32Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 12, this.#useAstronomicalChatzos, Uint8Array); + } + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + static _fromFFI(internalConstructor, ptr) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("CalculatorConfig._fromFFI is not meant to be called externally. Please use the default constructor."); + } + let structObj = {}; + const candleLightingOffsetMinutesDeref = (new Int32Array(wasm.memory.buffer, ptr, 1))[0]; + structObj.candleLightingOffsetMinutes = candleLightingOffsetMinutesDeref; + const useAstronomicalChatzosForOtherZmanimDeref = (new Uint8Array(wasm.memory.buffer, ptr + 4, 1))[0] === 1; + structObj.useAstronomicalChatzosForOtherZmanim = useAstronomicalChatzosForOtherZmanimDeref; + const useElevationDeref = (new Uint8Array(wasm.memory.buffer, ptr + 5, 1))[0] === 1; + structObj.useElevation = useElevationDeref; + const ateretTorahSunsetOffsetMinutesDeref = (new Int32Array(wasm.memory.buffer, ptr + 8, 1))[0]; + structObj.ateretTorahSunsetOffsetMinutes = ateretTorahSunsetOffsetMinutesDeref; + const useAstronomicalChatzosDeref = (new Uint8Array(wasm.memory.buffer, ptr + 12, 1))[0] === 1; + structObj.useAstronomicalChatzos = useAstronomicalChatzosDeref; + + return new CalculatorConfig(structObj); + } + + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/Calendar.d.ts b/interop/packages/typescript/lib/Calendar.d.ts new file mode 100644 index 0000000..5d0b576 --- /dev/null +++ b/interop/packages/typescript/lib/Calendar.d.ts @@ -0,0 +1,46 @@ +// generated by diplomat-tool +import type { CivilDate } from "./CivilDate" +import type { CivilDate_obj } from "./CivilDate" +import type { HebrewDate } from "./HebrewDate" +import type { HebrewDate_obj } from "./HebrewDate" +import type { HolidayList } from "./HolidayList" +import type { ParshaCode } from "./ParshaCode" +import type { YearLengthTypeCode } from "./YearLengthTypeCode" +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + + + +/** + * Dart entry point: construct once and call instance methods. + */ +export class Calendar { + /** @internal */ + get ffiValue(): pointer; + + + gregorianToHebrew(date: CivilDate_obj): HebrewDate | null; + + hebrewToGregorian(date: HebrewDate_obj): CivilDate | null; + + holidaysOnDate(date: CivilDate_obj, inIsrael: boolean, useModernHolidays: boolean): HolidayList | null; + + isAssurBemelacha(date: CivilDate_obj, inIsrael: boolean): boolean | null; + + hasCandleLighting(date: CivilDate_obj, inIsrael: boolean): boolean | null; + + todaysParsha(date: CivilDate_obj, inIsrael: boolean): ParshaCode | null; + + specialParsha(date: CivilDate_obj, inIsrael: boolean): ParshaCode | null; + + upcomingParsha(date: CivilDate_obj, inIsrael: boolean): ParshaCode | null; + + daysInHebrewYear(year: number): number | null; + + daysInHebrewMonth(year: number, month: number): number | null; + + isHebrewLeapYear(year: number): boolean; + + cheshvanKislevKviah(year: number): YearLengthTypeCode | null; + + constructor(); +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/Calendar.mjs b/interop/packages/typescript/lib/Calendar.mjs new file mode 100644 index 0000000..4985d50 --- /dev/null +++ b/interop/packages/typescript/lib/Calendar.mjs @@ -0,0 +1,316 @@ +// generated by diplomat-tool +import { CivilDate } from "./CivilDate.mjs" +import { HebrewDate } from "./HebrewDate.mjs" +import { HolidayList } from "./HolidayList.mjs" +import { ParshaCode } from "./ParshaCode.mjs" +import { YearLengthTypeCode } from "./YearLengthTypeCode.mjs" +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + +const Calendar_box_destroy_registry = new FinalizationRegistry((ptr) => { + wasm.Calendar_destroy(ptr); +}); + +/** + * Dart entry point: construct once and call instance methods. + */ +export class Calendar { + // Internal ptr reference: + #ptr = null; + + // Lifetimes are only to keep dependencies alive. + // Since JS won't garbage collect until there are no incoming edges. + #selfEdge = []; + + #internalConstructor(symbol, ptr, selfEdge) { + if (symbol !== diplomatRuntime.internalConstructor) { + console.error("Calendar is an Opaque type. You cannot call its constructor."); + return; + } + this.#ptr = ptr; + this.#selfEdge = selfEdge; + + // Are we being borrowed? If not, we can register. + if (this.#selfEdge.length === 0) { + Calendar_box_destroy_registry.register(this, this.#ptr); + } + + return this; + } + /** @internal */ + get ffiValue() { + return this.#ptr; + } + + + #defaultConstructor() { + + const result = wasm.Calendar_new(); + + try { + return new Calendar(diplomatRuntime.internalConstructor, result, []); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + } + } + + gregorianToHebrew(date) { + let functionCleanupArena = new diplomatRuntime.CleanupArena(); + + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true); + + + const result = wasm.Calendar_gregorian_to_hebrew(diplomatReceive.buffer, this.ffiValue, CivilDate._fromSuppliedValue(diplomatRuntime.internalConstructor, date)._intoFFI(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(CivilDate._sizeBytes), functionCleanupArena, {}, false)); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return HebrewDate._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + functionCleanupArena.free(); + + diplomatReceive.free(); + } + } + + hebrewToGregorian(date) { + let functionCleanupArena = new diplomatRuntime.CleanupArena(); + + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true); + + + const result = wasm.Calendar_hebrew_to_gregorian(diplomatReceive.buffer, this.ffiValue, HebrewDate._fromSuppliedValue(diplomatRuntime.internalConstructor, date)._intoFFI(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(HebrewDate._sizeBytes), functionCleanupArena, {}, false)); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return CivilDate._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + functionCleanupArena.free(); + + diplomatReceive.free(); + } + } + + holidaysOnDate(date, inIsrael, useModernHolidays) { + let functionCleanupArena = new diplomatRuntime.CleanupArena(); + + + const result = wasm.Calendar_holidays_on_date(this.ffiValue, CivilDate._fromSuppliedValue(diplomatRuntime.internalConstructor, date)._intoFFI(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(CivilDate._sizeBytes), functionCleanupArena, {}, false), inIsrael, useModernHolidays); + + try { + return result === 0 ? null : new HolidayList(diplomatRuntime.internalConstructor, result, []); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + functionCleanupArena.free(); + + } + } + + isAssurBemelacha(date, inIsrael) { + let functionCleanupArena = new diplomatRuntime.CleanupArena(); + + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 2, 1, true); + + + const result = wasm.Calendar_is_assur_bemelacha(diplomatReceive.buffer, this.ffiValue, CivilDate._fromSuppliedValue(diplomatRuntime.internalConstructor, date)._intoFFI(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(CivilDate._sizeBytes), functionCleanupArena, {}, false), inIsrael); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return (new Uint8Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0] === 1; + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + functionCleanupArena.free(); + + diplomatReceive.free(); + } + } + + hasCandleLighting(date, inIsrael) { + let functionCleanupArena = new diplomatRuntime.CleanupArena(); + + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 2, 1, true); + + + const result = wasm.Calendar_has_candle_lighting(diplomatReceive.buffer, this.ffiValue, CivilDate._fromSuppliedValue(diplomatRuntime.internalConstructor, date)._intoFFI(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(CivilDate._sizeBytes), functionCleanupArena, {}, false), inIsrael); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return (new Uint8Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0] === 1; + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + functionCleanupArena.free(); + + diplomatReceive.free(); + } + } + + todaysParsha(date, inIsrael) { + let functionCleanupArena = new diplomatRuntime.CleanupArena(); + + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); + + + const result = wasm.Calendar_todays_parsha(diplomatReceive.buffer, this.ffiValue, CivilDate._fromSuppliedValue(diplomatRuntime.internalConstructor, date)._intoFFI(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(CivilDate._sizeBytes), functionCleanupArena, {}, false), inIsrael); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + functionCleanupArena.free(); + + diplomatReceive.free(); + } + } + + specialParsha(date, inIsrael) { + let functionCleanupArena = new diplomatRuntime.CleanupArena(); + + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); + + + const result = wasm.Calendar_special_parsha(diplomatReceive.buffer, this.ffiValue, CivilDate._fromSuppliedValue(diplomatRuntime.internalConstructor, date)._intoFFI(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(CivilDate._sizeBytes), functionCleanupArena, {}, false), inIsrael); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + functionCleanupArena.free(); + + diplomatReceive.free(); + } + } + + upcomingParsha(date, inIsrael) { + let functionCleanupArena = new diplomatRuntime.CleanupArena(); + + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); + + + const result = wasm.Calendar_upcoming_parsha(diplomatReceive.buffer, this.ffiValue, CivilDate._fromSuppliedValue(diplomatRuntime.internalConstructor, date)._intoFFI(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(CivilDate._sizeBytes), functionCleanupArena, {}, false), inIsrael); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + functionCleanupArena.free(); + + diplomatReceive.free(); + } + } + + daysInHebrewYear(year) { + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); + + + const result = wasm.Calendar_days_in_hebrew_year(diplomatReceive.buffer, this.ffiValue, year); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return (new Int32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0]; + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + diplomatReceive.free(); + } + } + + daysInHebrewMonth(year, month) { + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 2, 1, true); + + + const result = wasm.Calendar_days_in_hebrew_month(diplomatReceive.buffer, this.ffiValue, year, month); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return (new Uint8Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0]; + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + diplomatReceive.free(); + } + } + + isHebrewLeapYear(year) { + + const result = wasm.Calendar_is_hebrew_leap_year(this.ffiValue, year); + + try { + return result; + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + } + } + + cheshvanKislevKviah(year) { + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); + + + const result = wasm.Calendar_cheshvan_kislev_kviah(diplomatReceive.buffer, this.ffiValue, year); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return new YearLengthTypeCode(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + diplomatReceive.free(); + } + } + + constructor() { + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/CivilDate.d.ts b/interop/packages/typescript/lib/CivilDate.d.ts new file mode 100644 index 0000000..e471dda --- /dev/null +++ b/interop/packages/typescript/lib/CivilDate.d.ts @@ -0,0 +1,31 @@ +// generated by diplomat-tool +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + +export type CivilDate_obj = { + year: number; + month: number; + day: number; +}; + + + +/** + * Gregorian civil date (year, month, day). + */ +export class CivilDate { + get year(): number; + set year(value: number); + get month(): number; + set month(value: number); + get day(): number; + set day(value: number); + /** @internal */ + static fromFields(structObj : CivilDate_obj) : CivilDate; + + /** + * Create `CivilDate` from an object that contains all of `CivilDate`s fields. + * Optional fields do not need to be included in the provided object. + */ + constructor(structObj: CivilDate_obj); + +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/CivilDate.mjs b/interop/packages/typescript/lib/CivilDate.mjs new file mode 100644 index 0000000..59a46a4 --- /dev/null +++ b/interop/packages/typescript/lib/CivilDate.mjs @@ -0,0 +1,132 @@ +// generated by diplomat-tool +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +/** + * Gregorian civil date (year, month, day). + */ +export class CivilDate { + #year; + get year() { + return this.#year; + } + set year(value){ + this.#year = value; + } + #month; + get month() { + return this.#month; + } + set month(value){ + this.#month = value; + } + #day; + get day() { + return this.#day; + } + set day(value){ + this.#day = value; + } + /** @internal */ + static fromFields(structObj) { + return new CivilDate(structObj); + } + + #internalConstructor(structObj) { + if (typeof structObj !== "object") { + throw new Error("CivilDate's constructor takes an object of CivilDate's fields."); + } + + if ("year" in structObj) { + this.#year = structObj.year; + } else { + throw new Error("Missing required field year."); + } + + if ("month" in structObj) { + this.#month = structObj.month; + } else { + throw new Error("Missing required field month."); + } + + if ("day" in structObj) { + this.#day = structObj.day; + } else { + throw new Error("Missing required field day."); + } + + return this; + } + + // Return this struct in FFI function friendly format. + // Returns an array that can be expanded with spread syntax (...) + _intoFFI( + dst, + functionCleanupArena, + appendArrayMap + ) { + + this._writeToArrayBuffer(wasm.memory.buffer, dst, functionCleanupArena, appendArrayMap); + + return dst; + } + + static get _sizeBytes() { + return 8; + } + + /// Currently unused, we may want to use later on though: + static get _sizeAlign() { + return 4; + } + + static _fromSuppliedValue(internalConstructor, obj) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("_fromSuppliedValue cannot be called externally."); + } + + if (obj instanceof CivilDate) { + return obj; + } + + return CivilDate.fromFields(obj); + } + + _writeToArrayBuffer( + arrayBuffer, + offset, + functionCleanupArena, + appendArrayMap + ) { + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#year, Int32Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 4, this.#month, Uint8Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 5, this.#day, Uint8Array); + } + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + static _fromFFI(internalConstructor, ptr) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("CivilDate._fromFFI is not meant to be called externally. Please use the default constructor."); + } + let structObj = {}; + const yearDeref = (new Int32Array(wasm.memory.buffer, ptr, 1))[0]; + structObj.year = yearDeref; + const monthDeref = (new Uint8Array(wasm.memory.buffer, ptr + 4, 1))[0]; + structObj.month = monthDeref; + const dayDeref = (new Uint8Array(wasm.memory.buffer, ptr + 5, 1))[0]; + structObj.day = dayDeref; + + return new CivilDate(structObj); + } + + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/DafResult.d.ts b/interop/packages/typescript/lib/DafResult.d.ts new file mode 100644 index 0000000..3e09181 --- /dev/null +++ b/interop/packages/typescript/lib/DafResult.d.ts @@ -0,0 +1,26 @@ +// generated by diplomat-tool +import type { TractateCode } from "./TractateCode" +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + +export type DafResult_obj = { + tractate: TractateCode; + page: number; +}; + + + +export class DafResult { + get tractate(): TractateCode; + set tractate(value: TractateCode); + get page(): number; + set page(value: number); + /** @internal */ + static fromFields(structObj : DafResult_obj) : DafResult; + + /** + * Create `DafResult` from an object that contains all of `DafResult`s fields. + * Optional fields do not need to be included in the provided object. + */ + constructor(structObj: DafResult_obj); + +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/DafResult.mjs b/interop/packages/typescript/lib/DafResult.mjs new file mode 100644 index 0000000..e215846 --- /dev/null +++ b/interop/packages/typescript/lib/DafResult.mjs @@ -0,0 +1,114 @@ +// generated by diplomat-tool +import { TractateCode } from "./TractateCode.mjs" +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +export class DafResult { + #tractate; + get tractate() { + return this.#tractate; + } + set tractate(value){ + this.#tractate = value; + } + #page; + get page() { + return this.#page; + } + set page(value){ + this.#page = value; + } + /** @internal */ + static fromFields(structObj) { + return new DafResult(structObj); + } + + #internalConstructor(structObj) { + if (typeof structObj !== "object") { + throw new Error("DafResult's constructor takes an object of DafResult's fields."); + } + + if ("tractate" in structObj) { + this.#tractate = structObj.tractate; + } else { + throw new Error("Missing required field tractate."); + } + + if ("page" in structObj) { + this.#page = structObj.page; + } else { + throw new Error("Missing required field page."); + } + + return this; + } + + // Return this struct in FFI function friendly format. + // Returns an array that can be expanded with spread syntax (...) + _intoFFI( + dst, + functionCleanupArena, + appendArrayMap + ) { + + this._writeToArrayBuffer(wasm.memory.buffer, dst, functionCleanupArena, appendArrayMap); + + return dst; + } + + static get _sizeBytes() { + return 8; + } + + /// Currently unused, we may want to use later on though: + static get _sizeAlign() { + return 4; + } + + static _fromSuppliedValue(internalConstructor, obj) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("_fromSuppliedValue cannot be called externally."); + } + + if (obj instanceof DafResult) { + return obj; + } + + return DafResult.fromFields(obj); + } + + _writeToArrayBuffer( + arrayBuffer, + offset, + functionCleanupArena, + appendArrayMap + ) { + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#tractate.ffiValue, Int32Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 4, this.#page, Uint16Array); + } + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + static _fromFFI(internalConstructor, ptr) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("DafResult._fromFFI is not meant to be called externally. Please use the default constructor."); + } + let structObj = {}; + const tractateDeref = diplomatRuntime.enumDiscriminant(wasm, ptr); + structObj.tractate = new TractateCode(diplomatRuntime.internalConstructor, tractateDeref); + const pageDeref = (new Uint16Array(wasm.memory.buffer, ptr + 4, 1))[0]; + structObj.page = pageDeref; + + return new DafResult(structObj); + } + + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/FfiLocation.d.ts b/interop/packages/typescript/lib/FfiLocation.d.ts new file mode 100644 index 0000000..8d7f8a0 --- /dev/null +++ b/interop/packages/typescript/lib/FfiLocation.d.ts @@ -0,0 +1,18 @@ +// generated by diplomat-tool +import type { ZmanimErrorCode } from "./ZmanimErrorCode" +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + + + +export class FfiLocation { + /** @internal */ + get ffiValue(): pointer; + /** @internal */ + constructor(); + + + /** + * Creates a location. Pass an empty timezone string when unknown. + */ + static new_(latitude: number, longitude: number, elevation: number, timezoneIana: string): FfiLocation; +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/FfiLocation.mjs b/interop/packages/typescript/lib/FfiLocation.mjs new file mode 100644 index 0000000..f5145b7 --- /dev/null +++ b/interop/packages/typescript/lib/FfiLocation.mjs @@ -0,0 +1,70 @@ +// generated by diplomat-tool +import { ZmanimErrorCode } from "./ZmanimErrorCode.mjs" +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + +const FfiLocation_box_destroy_registry = new FinalizationRegistry((ptr) => { + wasm.FfiLocation_destroy(ptr); +}); + +export class FfiLocation { + // Internal ptr reference: + #ptr = null; + + // Lifetimes are only to keep dependencies alive. + // Since JS won't garbage collect until there are no incoming edges. + #selfEdge = []; + + #internalConstructor(symbol, ptr, selfEdge) { + if (symbol !== diplomatRuntime.internalConstructor) { + console.error("FfiLocation is an Opaque type. You cannot call its constructor."); + return; + } + this.#ptr = ptr; + this.#selfEdge = selfEdge; + + // Are we being borrowed? If not, we can register. + if (this.#selfEdge.length === 0) { + FfiLocation_box_destroy_registry.register(this, this.#ptr); + } + + return this; + } + /** @internal */ + get ffiValue() { + return this.#ptr; + } + + + /** + * Creates a location. Pass an empty timezone string when unknown. + */ + static new_(latitude, longitude, elevation, timezoneIana) { + let functionCleanupArena = new diplomatRuntime.CleanupArena(); + + const timezoneIanaSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, timezoneIana))); + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); + + + const result = wasm.FfiLocation_new(diplomatReceive.buffer, latitude, longitude, elevation, timezoneIanaSlice.ptr); + + try { + if (!diplomatReceive.resultFlag) { + const cause = new ZmanimErrorCode(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); + throw new globalThis.Error('ZmanimErrorCode.' + cause.value, { cause }); + } + return new FfiLocation(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + functionCleanupArena.free(); + + diplomatReceive.free(); + } + } + + constructor(symbol, ptr, selfEdge) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/FfiZmanimCalculator.d.ts b/interop/packages/typescript/lib/FfiZmanimCalculator.d.ts new file mode 100644 index 0000000..024cbb5 --- /dev/null +++ b/interop/packages/typescript/lib/FfiZmanimCalculator.d.ts @@ -0,0 +1,25 @@ +// generated by diplomat-tool +import type { CalculatorConfig } from "./CalculatorConfig" +import type { CalculatorConfig_obj } from "./CalculatorConfig" +import type { FfiLocation } from "./FfiLocation" +import type { ZmanimErrorCode } from "./ZmanimErrorCode" +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + + + +export class FfiZmanimCalculator { + /** @internal */ + get ffiValue(): pointer; + /** @internal */ + constructor(); + + + static new_(location: FfiLocation, year: number, month: number, day: number, config: CalculatorConfig_obj): FfiZmanimCalculator | null; + + /** + * Calculates a zman preset by index, returning UTC epoch milliseconds. + * + * The index matches {@link ZmanPresetId} in the generated {@link crate::zman_preset} module. + */ + calculateZmanByIndex(presetIndex: number): bigint; +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/FfiZmanimCalculator.mjs b/interop/packages/typescript/lib/FfiZmanimCalculator.mjs new file mode 100644 index 0000000..78dc1c8 --- /dev/null +++ b/interop/packages/typescript/lib/FfiZmanimCalculator.mjs @@ -0,0 +1,86 @@ +// generated by diplomat-tool +import { CalculatorConfig } from "./CalculatorConfig.mjs" +import { FfiLocation } from "./FfiLocation.mjs" +import { ZmanimErrorCode } from "./ZmanimErrorCode.mjs" +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + +const FfiZmanimCalculator_box_destroy_registry = new FinalizationRegistry((ptr) => { + wasm.FfiZmanimCalculator_destroy(ptr); +}); + +export class FfiZmanimCalculator { + // Internal ptr reference: + #ptr = null; + + // Lifetimes are only to keep dependencies alive. + // Since JS won't garbage collect until there are no incoming edges. + #selfEdge = []; + + #internalConstructor(symbol, ptr, selfEdge) { + if (symbol !== diplomatRuntime.internalConstructor) { + console.error("FfiZmanimCalculator is an Opaque type. You cannot call its constructor."); + return; + } + this.#ptr = ptr; + this.#selfEdge = selfEdge; + + // Are we being borrowed? If not, we can register. + if (this.#selfEdge.length === 0) { + FfiZmanimCalculator_box_destroy_registry.register(this, this.#ptr); + } + + return this; + } + /** @internal */ + get ffiValue() { + return this.#ptr; + } + + + static new_(location, year, month, day, config) { + let functionCleanupArena = new diplomatRuntime.CleanupArena(); + + + const result = wasm.FfiZmanimCalculator_new(location.ffiValue, year, month, day, CalculatorConfig._fromSuppliedValue(diplomatRuntime.internalConstructor, config)._intoFFI(diplomatRuntime.FUNCTION_PARAM_ALLOC.alloc(CalculatorConfig._sizeBytes), functionCleanupArena, {}, false)); + + try { + return result === 0 ? null : new FfiZmanimCalculator(diplomatRuntime.internalConstructor, result, []); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + functionCleanupArena.free(); + + } + } + + /** + * Calculates a zman preset by index, returning UTC epoch milliseconds. + * + * The index matches {@link ZmanPresetId} in the generated {@link crate::zman_preset} module. + */ + calculateZmanByIndex(presetIndex) { + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 8, true); + + + const result = wasm.FfiZmanimCalculator_calculate_zman_by_index(diplomatReceive.buffer, this.ffiValue, presetIndex); + + try { + if (!diplomatReceive.resultFlag) { + const cause = new ZmanimErrorCode(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); + throw new globalThis.Error('ZmanimErrorCode.' + cause.value, { cause }); + } + return (new BigInt64Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0]; + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + diplomatReceive.free(); + } + } + + constructor(symbol, ptr, selfEdge) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/HebrewDate.d.ts b/interop/packages/typescript/lib/HebrewDate.d.ts new file mode 100644 index 0000000..6ea568d --- /dev/null +++ b/interop/packages/typescript/lib/HebrewDate.d.ts @@ -0,0 +1,31 @@ +// generated by diplomat-tool +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + +export type HebrewDate_obj = { + year: number; + month: number; + day: number; +}; + + + +/** + * Hebrew calendar date (year, month code, day). + */ +export class HebrewDate { + get year(): number; + set year(value: number); + get month(): number; + set month(value: number); + get day(): number; + set day(value: number); + /** @internal */ + static fromFields(structObj : HebrewDate_obj) : HebrewDate; + + /** + * Create `HebrewDate` from an object that contains all of `HebrewDate`s fields. + * Optional fields do not need to be included in the provided object. + */ + constructor(structObj: HebrewDate_obj); + +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/HebrewDate.mjs b/interop/packages/typescript/lib/HebrewDate.mjs new file mode 100644 index 0000000..8eebe10 --- /dev/null +++ b/interop/packages/typescript/lib/HebrewDate.mjs @@ -0,0 +1,132 @@ +// generated by diplomat-tool +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +/** + * Hebrew calendar date (year, month code, day). + */ +export class HebrewDate { + #year; + get year() { + return this.#year; + } + set year(value){ + this.#year = value; + } + #month; + get month() { + return this.#month; + } + set month(value){ + this.#month = value; + } + #day; + get day() { + return this.#day; + } + set day(value){ + this.#day = value; + } + /** @internal */ + static fromFields(structObj) { + return new HebrewDate(structObj); + } + + #internalConstructor(structObj) { + if (typeof structObj !== "object") { + throw new Error("HebrewDate's constructor takes an object of HebrewDate's fields."); + } + + if ("year" in structObj) { + this.#year = structObj.year; + } else { + throw new Error("Missing required field year."); + } + + if ("month" in structObj) { + this.#month = structObj.month; + } else { + throw new Error("Missing required field month."); + } + + if ("day" in structObj) { + this.#day = structObj.day; + } else { + throw new Error("Missing required field day."); + } + + return this; + } + + // Return this struct in FFI function friendly format. + // Returns an array that can be expanded with spread syntax (...) + _intoFFI( + dst, + functionCleanupArena, + appendArrayMap + ) { + + this._writeToArrayBuffer(wasm.memory.buffer, dst, functionCleanupArena, appendArrayMap); + + return dst; + } + + static get _sizeBytes() { + return 8; + } + + /// Currently unused, we may want to use later on though: + static get _sizeAlign() { + return 4; + } + + static _fromSuppliedValue(internalConstructor, obj) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("_fromSuppliedValue cannot be called externally."); + } + + if (obj instanceof HebrewDate) { + return obj; + } + + return HebrewDate.fromFields(obj); + } + + _writeToArrayBuffer( + arrayBuffer, + offset, + functionCleanupArena, + appendArrayMap + ) { + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#year, Int32Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 4, this.#month, Uint8Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 5, this.#day, Uint8Array); + } + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + static _fromFFI(internalConstructor, ptr) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("HebrewDate._fromFFI is not meant to be called externally. Please use the default constructor."); + } + let structObj = {}; + const yearDeref = (new Int32Array(wasm.memory.buffer, ptr, 1))[0]; + structObj.year = yearDeref; + const monthDeref = (new Uint8Array(wasm.memory.buffer, ptr + 4, 1))[0]; + structObj.month = monthDeref; + const dayDeref = (new Uint8Array(wasm.memory.buffer, ptr + 5, 1))[0]; + structObj.day = dayDeref; + + return new HebrewDate(structObj); + } + + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/HolidayCode.d.ts b/interop/packages/typescript/lib/HolidayCode.d.ts new file mode 100644 index 0000000..819bb46 --- /dev/null +++ b/interop/packages/typescript/lib/HolidayCode.d.ts @@ -0,0 +1,61 @@ +// generated by diplomat-tool +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + + + +export class HolidayCode { + + /** @internal */ + static fromValue(value: HolidayCode | string): HolidayCode; + + get value(): string; + + /** @internal */ + get ffiValue(): number; + + static ErevPesach : HolidayCode; + static Pesach : HolidayCode; + static CholHamoedPesach : HolidayCode; + static PesachSheni : HolidayCode; + static ErevShavuos : HolidayCode; + static Shavuos : HolidayCode; + static SeventeenthOfTammuz : HolidayCode; + static TishahBav : HolidayCode; + static TuBav : HolidayCode; + static ErevRoshHashana : HolidayCode; + static RoshHashana : HolidayCode; + static FastOfGedalyah : HolidayCode; + static ErevYomKippur : HolidayCode; + static YomKippur : HolidayCode; + static ErevSuccos : HolidayCode; + static Succos : HolidayCode; + static CholHamoedSuccos : HolidayCode; + static HoshanaRabbah : HolidayCode; + static SheminiAtzeres : HolidayCode; + static SimchasTorah : HolidayCode; + static Chanukah : HolidayCode; + static TenthOfTeves : HolidayCode; + static TuBshvat : HolidayCode; + static FastOfEsther : HolidayCode; + static Purim : HolidayCode; + static ShushanPurim : HolidayCode; + static PurimKatan : HolidayCode; + static RoshChodesh : HolidayCode; + static YomHaShoah : HolidayCode; + static YomHazikaron : HolidayCode; + static YomHaatzmaut : HolidayCode; + static YomYerushalayim : HolidayCode; + static LagBomer : HolidayCode; + static ShushanPurimKatan : HolidayCode; + static IsruChag : HolidayCode; + static YomKippurKatan : HolidayCode; + static Behab : HolidayCode; + static FastOfTheFirstborn : HolidayCode; + static CountOfTheOmer : HolidayCode; + static BirchasHachamah : HolidayCode; + static MacharHachodesh : HolidayCode; + static ShabbosMevarchim : HolidayCode; + + + constructor(value: HolidayCode | string ); +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/HolidayCode.mjs b/interop/packages/typescript/lib/HolidayCode.mjs new file mode 100644 index 0000000..b755931 --- /dev/null +++ b/interop/packages/typescript/lib/HolidayCode.mjs @@ -0,0 +1,189 @@ +// generated by diplomat-tool +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +export class HolidayCode { + #value = undefined; + + static #values = new Map([ + ["ErevPesach", 0], + ["Pesach", 1], + ["CholHamoedPesach", 2], + ["PesachSheni", 3], + ["ErevShavuos", 4], + ["Shavuos", 5], + ["SeventeenthOfTammuz", 6], + ["TishahBav", 7], + ["TuBav", 8], + ["ErevRoshHashana", 9], + ["RoshHashana", 10], + ["FastOfGedalyah", 11], + ["ErevYomKippur", 12], + ["YomKippur", 13], + ["ErevSuccos", 14], + ["Succos", 15], + ["CholHamoedSuccos", 16], + ["HoshanaRabbah", 17], + ["SheminiAtzeres", 18], + ["SimchasTorah", 19], + ["Chanukah", 20], + ["TenthOfTeves", 21], + ["TuBshvat", 22], + ["FastOfEsther", 23], + ["Purim", 24], + ["ShushanPurim", 25], + ["PurimKatan", 26], + ["RoshChodesh", 27], + ["YomHaShoah", 28], + ["YomHazikaron", 29], + ["YomHaatzmaut", 30], + ["YomYerushalayim", 31], + ["LagBomer", 32], + ["ShushanPurimKatan", 33], + ["IsruChag", 34], + ["YomKippurKatan", 35], + ["Behab", 36], + ["FastOfTheFirstborn", 37], + ["CountOfTheOmer", 38], + ["BirchasHachamah", 39], + ["MacharHachodesh", 40], + ["ShabbosMevarchim", 41] + ]); + + static getAllEntries() { + return HolidayCode.#values.entries(); + } + + #internalConstructor(value) { + if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { + // We pass in two internalConstructor arguments to create *new* + // instances of this type, otherwise the enums are treated as singletons. + if (arguments[1] === diplomatRuntime.internalConstructor ) { + this.#value = arguments[2]; + return this; + } + return HolidayCode.#objectValues[arguments[1]]; + } + + if (value instanceof HolidayCode) { + return value; + } + + let intVal = HolidayCode.#values.get(value); + + // Nullish check, checks for null or undefined + if (intVal != null) { + return HolidayCode.#objectValues[intVal]; + } + + throw TypeError(value + " is not a HolidayCode and does not correspond to any of its enumerator values."); + } + + /** @internal */ + static fromValue(value) { + return new HolidayCode(value); + } + + get value(){ + return [...HolidayCode.#values.keys()][this.#value]; + } + + /** @internal */ + get ffiValue(){ + return this.#value; + } + static #objectValues = [ + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 6), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 7), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 8), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 9), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 10), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 11), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 12), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 13), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 14), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 15), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 16), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 17), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 18), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 19), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 20), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 21), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 22), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 23), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 24), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 25), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 26), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 27), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 28), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 29), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 30), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 31), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 32), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 33), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 34), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 35), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 36), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 37), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 38), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 39), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 40), + new HolidayCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 41), + ]; + + static ErevPesach = HolidayCode.#objectValues[0]; + static Pesach = HolidayCode.#objectValues[1]; + static CholHamoedPesach = HolidayCode.#objectValues[2]; + static PesachSheni = HolidayCode.#objectValues[3]; + static ErevShavuos = HolidayCode.#objectValues[4]; + static Shavuos = HolidayCode.#objectValues[5]; + static SeventeenthOfTammuz = HolidayCode.#objectValues[6]; + static TishahBav = HolidayCode.#objectValues[7]; + static TuBav = HolidayCode.#objectValues[8]; + static ErevRoshHashana = HolidayCode.#objectValues[9]; + static RoshHashana = HolidayCode.#objectValues[10]; + static FastOfGedalyah = HolidayCode.#objectValues[11]; + static ErevYomKippur = HolidayCode.#objectValues[12]; + static YomKippur = HolidayCode.#objectValues[13]; + static ErevSuccos = HolidayCode.#objectValues[14]; + static Succos = HolidayCode.#objectValues[15]; + static CholHamoedSuccos = HolidayCode.#objectValues[16]; + static HoshanaRabbah = HolidayCode.#objectValues[17]; + static SheminiAtzeres = HolidayCode.#objectValues[18]; + static SimchasTorah = HolidayCode.#objectValues[19]; + static Chanukah = HolidayCode.#objectValues[20]; + static TenthOfTeves = HolidayCode.#objectValues[21]; + static TuBshvat = HolidayCode.#objectValues[22]; + static FastOfEsther = HolidayCode.#objectValues[23]; + static Purim = HolidayCode.#objectValues[24]; + static ShushanPurim = HolidayCode.#objectValues[25]; + static PurimKatan = HolidayCode.#objectValues[26]; + static RoshChodesh = HolidayCode.#objectValues[27]; + static YomHaShoah = HolidayCode.#objectValues[28]; + static YomHazikaron = HolidayCode.#objectValues[29]; + static YomHaatzmaut = HolidayCode.#objectValues[30]; + static YomYerushalayim = HolidayCode.#objectValues[31]; + static LagBomer = HolidayCode.#objectValues[32]; + static ShushanPurimKatan = HolidayCode.#objectValues[33]; + static IsruChag = HolidayCode.#objectValues[34]; + static YomKippurKatan = HolidayCode.#objectValues[35]; + static Behab = HolidayCode.#objectValues[36]; + static FastOfTheFirstborn = HolidayCode.#objectValues[37]; + static CountOfTheOmer = HolidayCode.#objectValues[38]; + static BirchasHachamah = HolidayCode.#objectValues[39]; + static MacharHachodesh = HolidayCode.#objectValues[40]; + static ShabbosMevarchim = HolidayCode.#objectValues[41]; + + + constructor(value) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/HolidayEntry.d.ts b/interop/packages/typescript/lib/HolidayEntry.d.ts new file mode 100644 index 0000000..b4af02c --- /dev/null +++ b/interop/packages/typescript/lib/HolidayEntry.d.ts @@ -0,0 +1,29 @@ +// generated by diplomat-tool +import type { HolidayCode } from "./HolidayCode" +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + +export type HolidayEntry_obj = { + code: HolidayCode; + subDay: number; +}; + + + +/** + * A holiday occurring on a date, with an optional sub-day (Chanukah, Omer). + */ +export class HolidayEntry { + get code(): HolidayCode; + set code(value: HolidayCode); + get subDay(): number; + set subDay(value: number); + /** @internal */ + static fromFields(structObj : HolidayEntry_obj) : HolidayEntry; + + /** + * Create `HolidayEntry` from an object that contains all of `HolidayEntry`s fields. + * Optional fields do not need to be included in the provided object. + */ + constructor(structObj: HolidayEntry_obj); + +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/HolidayEntry.mjs b/interop/packages/typescript/lib/HolidayEntry.mjs new file mode 100644 index 0000000..f51e266 --- /dev/null +++ b/interop/packages/typescript/lib/HolidayEntry.mjs @@ -0,0 +1,117 @@ +// generated by diplomat-tool +import { HolidayCode } from "./HolidayCode.mjs" +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +/** + * A holiday occurring on a date, with an optional sub-day (Chanukah, Omer). + */ +export class HolidayEntry { + #code; + get code() { + return this.#code; + } + set code(value){ + this.#code = value; + } + #subDay; + get subDay() { + return this.#subDay; + } + set subDay(value){ + this.#subDay = value; + } + /** @internal */ + static fromFields(structObj) { + return new HolidayEntry(structObj); + } + + #internalConstructor(structObj) { + if (typeof structObj !== "object") { + throw new Error("HolidayEntry's constructor takes an object of HolidayEntry's fields."); + } + + if ("code" in structObj) { + this.#code = structObj.code; + } else { + throw new Error("Missing required field code."); + } + + if ("subDay" in structObj) { + this.#subDay = structObj.subDay; + } else { + throw new Error("Missing required field subDay."); + } + + return this; + } + + // Return this struct in FFI function friendly format. + // Returns an array that can be expanded with spread syntax (...) + _intoFFI( + dst, + functionCleanupArena, + appendArrayMap + ) { + + this._writeToArrayBuffer(wasm.memory.buffer, dst, functionCleanupArena, appendArrayMap); + + return dst; + } + + static get _sizeBytes() { + return 8; + } + + /// Currently unused, we may want to use later on though: + static get _sizeAlign() { + return 4; + } + + static _fromSuppliedValue(internalConstructor, obj) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("_fromSuppliedValue cannot be called externally."); + } + + if (obj instanceof HolidayEntry) { + return obj; + } + + return HolidayEntry.fromFields(obj); + } + + _writeToArrayBuffer( + arrayBuffer, + offset, + functionCleanupArena, + appendArrayMap + ) { + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#code.ffiValue, Int32Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 4, this.#subDay, Uint8Array); + } + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + static _fromFFI(internalConstructor, ptr) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("HolidayEntry._fromFFI is not meant to be called externally. Please use the default constructor."); + } + let structObj = {}; + const codeDeref = diplomatRuntime.enumDiscriminant(wasm, ptr); + structObj.code = new HolidayCode(diplomatRuntime.internalConstructor, codeDeref); + const subDayDeref = (new Uint8Array(wasm.memory.buffer, ptr + 4, 1))[0]; + structObj.subDay = subDayDeref; + + return new HolidayEntry(structObj); + } + + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/HolidayList.d.ts b/interop/packages/typescript/lib/HolidayList.d.ts new file mode 100644 index 0000000..7dd7af7 --- /dev/null +++ b/interop/packages/typescript/lib/HolidayList.d.ts @@ -0,0 +1,17 @@ +// generated by diplomat-tool +import type { HolidayEntry } from "./HolidayEntry" +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + + + +export class HolidayList { + /** @internal */ + get ffiValue(): pointer; + /** @internal */ + constructor(); + + + len(): number; + + get(index: number): HolidayEntry | null; +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/HolidayList.mjs b/interop/packages/typescript/lib/HolidayList.mjs new file mode 100644 index 0000000..2757069 --- /dev/null +++ b/interop/packages/typescript/lib/HolidayList.mjs @@ -0,0 +1,74 @@ +// generated by diplomat-tool +import { HolidayEntry } from "./HolidayEntry.mjs" +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + +const HolidayList_box_destroy_registry = new FinalizationRegistry((ptr) => { + wasm.HolidayList_destroy(ptr); +}); + +export class HolidayList { + // Internal ptr reference: + #ptr = null; + + // Lifetimes are only to keep dependencies alive. + // Since JS won't garbage collect until there are no incoming edges. + #selfEdge = []; + + #internalConstructor(symbol, ptr, selfEdge) { + if (symbol !== diplomatRuntime.internalConstructor) { + console.error("HolidayList is an Opaque type. You cannot call its constructor."); + return; + } + this.#ptr = ptr; + this.#selfEdge = selfEdge; + + // Are we being borrowed? If not, we can register. + if (this.#selfEdge.length === 0) { + HolidayList_box_destroy_registry.register(this, this.#ptr); + } + + return this; + } + /** @internal */ + get ffiValue() { + return this.#ptr; + } + + + len() { + + const result = wasm.HolidayList_len(this.ffiValue); + + try { + return result; + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + } + } + + get(index) { + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true); + + + const result = wasm.HolidayList_get(diplomatReceive.buffer, this.ffiValue, index); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return HolidayEntry._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + diplomatReceive.free(); + } + } + + constructor(symbol, ptr, selfEdge) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/Limudim.d.ts b/interop/packages/typescript/lib/Limudim.d.ts new file mode 100644 index 0000000..ba65f3a --- /dev/null +++ b/interop/packages/typescript/lib/Limudim.d.ts @@ -0,0 +1,34 @@ +// generated by diplomat-tool +import type { AmudResult } from "./AmudResult" +import type { DafResult } from "./DafResult" +import type { MishnasResult } from "./MishnasResult" +import type { PirkeiAvosResult } from "./PirkeiAvosResult" +import type { TehillimResult } from "./TehillimResult" +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + + + +/** + * Dart entry point: construct once and call instance methods. + */ +export class Limudim { + /** @internal */ + get ffiValue(): pointer; + + + dafYomiBavli(year: number, month: number, day: number): DafResult | null; + + dafYomiYerushalmi(year: number, month: number, day: number): DafResult | null; + + dafHashavuaBavli(year: number, month: number, day: number): DafResult | null; + + amudYomiBavliDirshu(year: number, month: number, day: number): AmudResult | null; + + mishnaYomis(year: number, month: number, day: number): MishnasResult | null; + + pirkeiAvos(year: number, month: number, day: number, inIsrael: boolean): PirkeiAvosResult | null; + + tehillimMonthly(year: number, month: number, day: number): TehillimResult | null; + + constructor(); +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/Limudim.mjs b/interop/packages/typescript/lib/Limudim.mjs new file mode 100644 index 0000000..d5563be --- /dev/null +++ b/interop/packages/typescript/lib/Limudim.mjs @@ -0,0 +1,201 @@ +// generated by diplomat-tool +import { AmudResult } from "./AmudResult.mjs" +import { DafResult } from "./DafResult.mjs" +import { MishnasResult } from "./MishnasResult.mjs" +import { PirkeiAvosResult } from "./PirkeiAvosResult.mjs" +import { TehillimResult } from "./TehillimResult.mjs" +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + +const Limudim_box_destroy_registry = new FinalizationRegistry((ptr) => { + wasm.Limudim_destroy(ptr); +}); + +/** + * Dart entry point: construct once and call instance methods. + */ +export class Limudim { + // Internal ptr reference: + #ptr = null; + + // Lifetimes are only to keep dependencies alive. + // Since JS won't garbage collect until there are no incoming edges. + #selfEdge = []; + + #internalConstructor(symbol, ptr, selfEdge) { + if (symbol !== diplomatRuntime.internalConstructor) { + console.error("Limudim is an Opaque type. You cannot call its constructor."); + return; + } + this.#ptr = ptr; + this.#selfEdge = selfEdge; + + // Are we being borrowed? If not, we can register. + if (this.#selfEdge.length === 0) { + Limudim_box_destroy_registry.register(this, this.#ptr); + } + + return this; + } + /** @internal */ + get ffiValue() { + return this.#ptr; + } + + + #defaultConstructor() { + + const result = wasm.Limudim_new(); + + try { + return new Limudim(diplomatRuntime.internalConstructor, result, []); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + } + } + + dafYomiBavli(year, month, day) { + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true); + + + const result = wasm.Limudim_daf_yomi_bavli(diplomatReceive.buffer, this.ffiValue, year, month, day); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return DafResult._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + diplomatReceive.free(); + } + } + + dafYomiYerushalmi(year, month, day) { + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true); + + + const result = wasm.Limudim_daf_yomi_yerushalmi(diplomatReceive.buffer, this.ffiValue, year, month, day); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return DafResult._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + diplomatReceive.free(); + } + } + + dafHashavuaBavli(year, month, day) { + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true); + + + const result = wasm.Limudim_daf_hashavua_bavli(diplomatReceive.buffer, this.ffiValue, year, month, day); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return DafResult._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + diplomatReceive.free(); + } + } + + amudYomiBavliDirshu(year, month, day) { + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 13, 4, true); + + + const result = wasm.Limudim_amud_yomi_bavli_dirshu(diplomatReceive.buffer, this.ffiValue, year, month, day); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return AmudResult._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + diplomatReceive.free(); + } + } + + mishnaYomis(year, month, day) { + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 25, 4, true); + + + const result = wasm.Limudim_mishna_yomis(diplomatReceive.buffer, this.ffiValue, year, month, day); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return MishnasResult._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + diplomatReceive.free(); + } + } + + pirkeiAvos(year, month, day, inIsrael) { + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 4, 1, true); + + + const result = wasm.Limudim_pirkei_avos(diplomatReceive.buffer, this.ffiValue, year, month, day, inIsrael); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return PirkeiAvosResult._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + diplomatReceive.free(); + } + } + + tehillimMonthly(year, month, day) { + const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 2, true); + + + const result = wasm.Limudim_tehillim_monthly(diplomatReceive.buffer, this.ffiValue, year, month, day); + + try { + if (!diplomatReceive.resultFlag) { + return null; + } + return TehillimResult._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + diplomatReceive.free(); + } + } + + constructor() { + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/MishnaResult.d.ts b/interop/packages/typescript/lib/MishnaResult.d.ts new file mode 100644 index 0000000..c333d23 --- /dev/null +++ b/interop/packages/typescript/lib/MishnaResult.d.ts @@ -0,0 +1,29 @@ +// generated by diplomat-tool +import type { TractateCode } from "./TractateCode" +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + +export type MishnaResult_obj = { + tractate: TractateCode; + chapter: number; + mishna: number; +}; + + + +export class MishnaResult { + get tractate(): TractateCode; + set tractate(value: TractateCode); + get chapter(): number; + set chapter(value: number); + get mishna(): number; + set mishna(value: number); + /** @internal */ + static fromFields(structObj : MishnaResult_obj) : MishnaResult; + + /** + * Create `MishnaResult` from an object that contains all of `MishnaResult`s fields. + * Optional fields do not need to be included in the provided object. + */ + constructor(structObj: MishnaResult_obj); + +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/MishnaResult.mjs b/interop/packages/typescript/lib/MishnaResult.mjs new file mode 100644 index 0000000..192c231 --- /dev/null +++ b/interop/packages/typescript/lib/MishnaResult.mjs @@ -0,0 +1,130 @@ +// generated by diplomat-tool +import { TractateCode } from "./TractateCode.mjs" +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +export class MishnaResult { + #tractate; + get tractate() { + return this.#tractate; + } + set tractate(value){ + this.#tractate = value; + } + #chapter; + get chapter() { + return this.#chapter; + } + set chapter(value){ + this.#chapter = value; + } + #mishna; + get mishna() { + return this.#mishna; + } + set mishna(value){ + this.#mishna = value; + } + /** @internal */ + static fromFields(structObj) { + return new MishnaResult(structObj); + } + + #internalConstructor(structObj) { + if (typeof structObj !== "object") { + throw new Error("MishnaResult's constructor takes an object of MishnaResult's fields."); + } + + if ("tractate" in structObj) { + this.#tractate = structObj.tractate; + } else { + throw new Error("Missing required field tractate."); + } + + if ("chapter" in structObj) { + this.#chapter = structObj.chapter; + } else { + throw new Error("Missing required field chapter."); + } + + if ("mishna" in structObj) { + this.#mishna = structObj.mishna; + } else { + throw new Error("Missing required field mishna."); + } + + return this; + } + + // Return this struct in FFI function friendly format. + // Returns an array that can be expanded with spread syntax (...) + _intoFFI( + dst, + functionCleanupArena, + appendArrayMap + ) { + + this._writeToArrayBuffer(wasm.memory.buffer, dst, functionCleanupArena, appendArrayMap); + + return dst; + } + + static get _sizeBytes() { + return 12; + } + + /// Currently unused, we may want to use later on though: + static get _sizeAlign() { + return 4; + } + + static _fromSuppliedValue(internalConstructor, obj) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("_fromSuppliedValue cannot be called externally."); + } + + if (obj instanceof MishnaResult) { + return obj; + } + + return MishnaResult.fromFields(obj); + } + + _writeToArrayBuffer( + arrayBuffer, + offset, + functionCleanupArena, + appendArrayMap + ) { + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#tractate.ffiValue, Int32Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 4, this.#chapter, Uint32Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 8, this.#mishna, Uint16Array); + } + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + static _fromFFI(internalConstructor, ptr) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("MishnaResult._fromFFI is not meant to be called externally. Please use the default constructor."); + } + let structObj = {}; + const tractateDeref = diplomatRuntime.enumDiscriminant(wasm, ptr); + structObj.tractate = new TractateCode(diplomatRuntime.internalConstructor, tractateDeref); + const chapterDeref = (new Uint32Array(wasm.memory.buffer, ptr + 4, 1))[0]; + structObj.chapter = chapterDeref; + const mishnaDeref = (new Uint16Array(wasm.memory.buffer, ptr + 8, 1))[0]; + structObj.mishna = mishnaDeref; + + return new MishnaResult(structObj); + } + + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/MishnasResult.d.ts b/interop/packages/typescript/lib/MishnasResult.d.ts new file mode 100644 index 0000000..c3b4d4c --- /dev/null +++ b/interop/packages/typescript/lib/MishnasResult.d.ts @@ -0,0 +1,27 @@ +// generated by diplomat-tool +import type { MishnaResult } from "./MishnaResult" +import type { MishnaResult_obj } from "./MishnaResult" +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + +export type MishnasResult_obj = { + start: MishnaResult_obj; + end: MishnaResult_obj; +}; + + + +export class MishnasResult { + get start(): MishnaResult; + set start(value: MishnaResult); + get end(): MishnaResult; + set end(value: MishnaResult); + /** @internal */ + static fromFields(structObj : MishnasResult_obj) : MishnasResult; + + /** + * Create `MishnasResult` from an object that contains all of `MishnasResult`s fields. + * Optional fields do not need to be included in the provided object. + */ + constructor(structObj: MishnasResult_obj); + +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/MishnasResult.mjs b/interop/packages/typescript/lib/MishnasResult.mjs new file mode 100644 index 0000000..ef5b710 --- /dev/null +++ b/interop/packages/typescript/lib/MishnasResult.mjs @@ -0,0 +1,114 @@ +// generated by diplomat-tool +import { MishnaResult } from "./MishnaResult.mjs" +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +export class MishnasResult { + #start; + get start() { + return this.#start; + } + set start(value){ + this.#start = value; + } + #end; + get end() { + return this.#end; + } + set end(value){ + this.#end = value; + } + /** @internal */ + static fromFields(structObj) { + return new MishnasResult(structObj); + } + + #internalConstructor(structObj) { + if (typeof structObj !== "object") { + throw new Error("MishnasResult's constructor takes an object of MishnasResult's fields."); + } + + if ("start" in structObj) { + this.#start = MishnaResult._fromSuppliedValue(diplomatRuntime.internalConstructor, structObj.start); + } else { + throw new Error("Missing required field start."); + } + + if ("end" in structObj) { + this.#end = MishnaResult._fromSuppliedValue(diplomatRuntime.internalConstructor, structObj.end); + } else { + throw new Error("Missing required field end."); + } + + return this; + } + + // Return this struct in FFI function friendly format. + // Returns an array that can be expanded with spread syntax (...) + _intoFFI( + dst, + functionCleanupArena, + appendArrayMap + ) { + + this._writeToArrayBuffer(wasm.memory.buffer, dst, functionCleanupArena, appendArrayMap); + + return dst; + } + + static get _sizeBytes() { + return 24; + } + + /// Currently unused, we may want to use later on though: + static get _sizeAlign() { + return 4; + } + + static _fromSuppliedValue(internalConstructor, obj) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("_fromSuppliedValue cannot be called externally."); + } + + if (obj instanceof MishnasResult) { + return obj; + } + + return MishnasResult.fromFields(obj); + } + + _writeToArrayBuffer( + arrayBuffer, + offset, + functionCleanupArena, + appendArrayMap + ) { + MishnaResult._fromSuppliedValue(diplomatRuntime.internalConstructor, this.#start)._writeToArrayBuffer(arrayBuffer, offset + 0, functionCleanupArena, {}); + MishnaResult._fromSuppliedValue(diplomatRuntime.internalConstructor, this.#end)._writeToArrayBuffer(arrayBuffer, offset + 12, functionCleanupArena, {}); + } + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + static _fromFFI(internalConstructor, ptr) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("MishnasResult._fromFFI is not meant to be called externally. Please use the default constructor."); + } + let structObj = {}; + const startDeref = ptr; + structObj.start = MishnaResult._fromFFI(diplomatRuntime.internalConstructor, startDeref); + const endDeref = ptr + 12; + structObj.end = MishnaResult._fromFFI(diplomatRuntime.internalConstructor, endDeref); + + return new MishnasResult(structObj); + } + + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/ParshaCode.d.ts b/interop/packages/typescript/lib/ParshaCode.d.ts new file mode 100644 index 0000000..852c6d8 --- /dev/null +++ b/interop/packages/typescript/lib/ParshaCode.d.ts @@ -0,0 +1,89 @@ +// generated by diplomat-tool +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + + + +export class ParshaCode { + + /** @internal */ + static fromValue(value: ParshaCode | string): ParshaCode; + + get value(): string; + + /** @internal */ + get ffiValue(): number; + + static Bereshis : ParshaCode; + static Noach : ParshaCode; + static LechLecha : ParshaCode; + static Vayera : ParshaCode; + static ChayeiSara : ParshaCode; + static Toldos : ParshaCode; + static Vayetzei : ParshaCode; + static Vayishlach : ParshaCode; + static Vayeshev : ParshaCode; + static Miketz : ParshaCode; + static Vayigash : ParshaCode; + static Vayechi : ParshaCode; + static Shemos : ParshaCode; + static Vaera : ParshaCode; + static Bo : ParshaCode; + static Beshalach : ParshaCode; + static Yisro : ParshaCode; + static Mishpatim : ParshaCode; + static Terumah : ParshaCode; + static Tetzaveh : ParshaCode; + static KiSisa : ParshaCode; + static Vayakhel : ParshaCode; + static Pekudei : ParshaCode; + static Vayikra : ParshaCode; + static Tzav : ParshaCode; + static Shmini : ParshaCode; + static Tazria : ParshaCode; + static Metzora : ParshaCode; + static AchreiMos : ParshaCode; + static Kedoshim : ParshaCode; + static Emor : ParshaCode; + static Behar : ParshaCode; + static Bechukosai : ParshaCode; + static Bamidbar : ParshaCode; + static Nasso : ParshaCode; + static Behaaloscha : ParshaCode; + static Shlach : ParshaCode; + static Korach : ParshaCode; + static Chukas : ParshaCode; + static Balak : ParshaCode; + static Pinchas : ParshaCode; + static Matos : ParshaCode; + static Masei : ParshaCode; + static Devarim : ParshaCode; + static Vaeschanan : ParshaCode; + static Eikev : ParshaCode; + static Reeh : ParshaCode; + static Shoftim : ParshaCode; + static KiSeitzei : ParshaCode; + static KiSavo : ParshaCode; + static Nitzavim : ParshaCode; + static Vayeilech : ParshaCode; + static HaAzinu : ParshaCode; + static VezosHabracha : ParshaCode; + static VayakhelPekudei : ParshaCode; + static TazriaMetzora : ParshaCode; + static AchreiMosKedoshim : ParshaCode; + static BeharBechukosai : ParshaCode; + static ChukasBalak : ParshaCode; + static MatosMasei : ParshaCode; + static NitzavimVayeilech : ParshaCode; + static Shekalim : ParshaCode; + static Zachor : ParshaCode; + static Parah : ParshaCode; + static Hachodesh : ParshaCode; + static Shuva : ParshaCode; + static Shira : ParshaCode; + static Hagadol : ParshaCode; + static Chazon : ParshaCode; + static Nachamu : ParshaCode; + + + constructor(value: ParshaCode | string ); +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/ParshaCode.mjs b/interop/packages/typescript/lib/ParshaCode.mjs new file mode 100644 index 0000000..56bdd82 --- /dev/null +++ b/interop/packages/typescript/lib/ParshaCode.mjs @@ -0,0 +1,273 @@ +// generated by diplomat-tool +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +export class ParshaCode { + #value = undefined; + + static #values = new Map([ + ["Bereshis", 0], + ["Noach", 1], + ["LechLecha", 2], + ["Vayera", 3], + ["ChayeiSara", 4], + ["Toldos", 5], + ["Vayetzei", 6], + ["Vayishlach", 7], + ["Vayeshev", 8], + ["Miketz", 9], + ["Vayigash", 10], + ["Vayechi", 11], + ["Shemos", 12], + ["Vaera", 13], + ["Bo", 14], + ["Beshalach", 15], + ["Yisro", 16], + ["Mishpatim", 17], + ["Terumah", 18], + ["Tetzaveh", 19], + ["KiSisa", 20], + ["Vayakhel", 21], + ["Pekudei", 22], + ["Vayikra", 23], + ["Tzav", 24], + ["Shmini", 25], + ["Tazria", 26], + ["Metzora", 27], + ["AchreiMos", 28], + ["Kedoshim", 29], + ["Emor", 30], + ["Behar", 31], + ["Bechukosai", 32], + ["Bamidbar", 33], + ["Nasso", 34], + ["Behaaloscha", 35], + ["Shlach", 36], + ["Korach", 37], + ["Chukas", 38], + ["Balak", 39], + ["Pinchas", 40], + ["Matos", 41], + ["Masei", 42], + ["Devarim", 43], + ["Vaeschanan", 44], + ["Eikev", 45], + ["Reeh", 46], + ["Shoftim", 47], + ["KiSeitzei", 48], + ["KiSavo", 49], + ["Nitzavim", 50], + ["Vayeilech", 51], + ["HaAzinu", 52], + ["VezosHabracha", 53], + ["VayakhelPekudei", 54], + ["TazriaMetzora", 55], + ["AchreiMosKedoshim", 56], + ["BeharBechukosai", 57], + ["ChukasBalak", 58], + ["MatosMasei", 59], + ["NitzavimVayeilech", 60], + ["Shekalim", 61], + ["Zachor", 62], + ["Parah", 63], + ["Hachodesh", 64], + ["Shuva", 65], + ["Shira", 66], + ["Hagadol", 67], + ["Chazon", 68], + ["Nachamu", 69] + ]); + + static getAllEntries() { + return ParshaCode.#values.entries(); + } + + #internalConstructor(value) { + if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { + // We pass in two internalConstructor arguments to create *new* + // instances of this type, otherwise the enums are treated as singletons. + if (arguments[1] === diplomatRuntime.internalConstructor ) { + this.#value = arguments[2]; + return this; + } + return ParshaCode.#objectValues[arguments[1]]; + } + + if (value instanceof ParshaCode) { + return value; + } + + let intVal = ParshaCode.#values.get(value); + + // Nullish check, checks for null or undefined + if (intVal != null) { + return ParshaCode.#objectValues[intVal]; + } + + throw TypeError(value + " is not a ParshaCode and does not correspond to any of its enumerator values."); + } + + /** @internal */ + static fromValue(value) { + return new ParshaCode(value); + } + + get value(){ + return [...ParshaCode.#values.keys()][this.#value]; + } + + /** @internal */ + get ffiValue(){ + return this.#value; + } + static #objectValues = [ + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 6), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 7), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 8), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 9), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 10), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 11), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 12), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 13), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 14), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 15), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 16), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 17), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 18), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 19), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 20), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 21), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 22), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 23), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 24), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 25), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 26), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 27), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 28), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 29), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 30), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 31), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 32), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 33), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 34), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 35), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 36), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 37), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 38), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 39), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 40), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 41), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 42), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 43), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 44), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 45), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 46), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 47), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 48), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 49), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 50), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 51), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 52), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 53), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 54), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 55), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 56), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 57), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 58), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 59), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 60), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 61), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 62), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 63), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 64), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 65), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 66), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 67), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 68), + new ParshaCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 69), + ]; + + static Bereshis = ParshaCode.#objectValues[0]; + static Noach = ParshaCode.#objectValues[1]; + static LechLecha = ParshaCode.#objectValues[2]; + static Vayera = ParshaCode.#objectValues[3]; + static ChayeiSara = ParshaCode.#objectValues[4]; + static Toldos = ParshaCode.#objectValues[5]; + static Vayetzei = ParshaCode.#objectValues[6]; + static Vayishlach = ParshaCode.#objectValues[7]; + static Vayeshev = ParshaCode.#objectValues[8]; + static Miketz = ParshaCode.#objectValues[9]; + static Vayigash = ParshaCode.#objectValues[10]; + static Vayechi = ParshaCode.#objectValues[11]; + static Shemos = ParshaCode.#objectValues[12]; + static Vaera = ParshaCode.#objectValues[13]; + static Bo = ParshaCode.#objectValues[14]; + static Beshalach = ParshaCode.#objectValues[15]; + static Yisro = ParshaCode.#objectValues[16]; + static Mishpatim = ParshaCode.#objectValues[17]; + static Terumah = ParshaCode.#objectValues[18]; + static Tetzaveh = ParshaCode.#objectValues[19]; + static KiSisa = ParshaCode.#objectValues[20]; + static Vayakhel = ParshaCode.#objectValues[21]; + static Pekudei = ParshaCode.#objectValues[22]; + static Vayikra = ParshaCode.#objectValues[23]; + static Tzav = ParshaCode.#objectValues[24]; + static Shmini = ParshaCode.#objectValues[25]; + static Tazria = ParshaCode.#objectValues[26]; + static Metzora = ParshaCode.#objectValues[27]; + static AchreiMos = ParshaCode.#objectValues[28]; + static Kedoshim = ParshaCode.#objectValues[29]; + static Emor = ParshaCode.#objectValues[30]; + static Behar = ParshaCode.#objectValues[31]; + static Bechukosai = ParshaCode.#objectValues[32]; + static Bamidbar = ParshaCode.#objectValues[33]; + static Nasso = ParshaCode.#objectValues[34]; + static Behaaloscha = ParshaCode.#objectValues[35]; + static Shlach = ParshaCode.#objectValues[36]; + static Korach = ParshaCode.#objectValues[37]; + static Chukas = ParshaCode.#objectValues[38]; + static Balak = ParshaCode.#objectValues[39]; + static Pinchas = ParshaCode.#objectValues[40]; + static Matos = ParshaCode.#objectValues[41]; + static Masei = ParshaCode.#objectValues[42]; + static Devarim = ParshaCode.#objectValues[43]; + static Vaeschanan = ParshaCode.#objectValues[44]; + static Eikev = ParshaCode.#objectValues[45]; + static Reeh = ParshaCode.#objectValues[46]; + static Shoftim = ParshaCode.#objectValues[47]; + static KiSeitzei = ParshaCode.#objectValues[48]; + static KiSavo = ParshaCode.#objectValues[49]; + static Nitzavim = ParshaCode.#objectValues[50]; + static Vayeilech = ParshaCode.#objectValues[51]; + static HaAzinu = ParshaCode.#objectValues[52]; + static VezosHabracha = ParshaCode.#objectValues[53]; + static VayakhelPekudei = ParshaCode.#objectValues[54]; + static TazriaMetzora = ParshaCode.#objectValues[55]; + static AchreiMosKedoshim = ParshaCode.#objectValues[56]; + static BeharBechukosai = ParshaCode.#objectValues[57]; + static ChukasBalak = ParshaCode.#objectValues[58]; + static MatosMasei = ParshaCode.#objectValues[59]; + static NitzavimVayeilech = ParshaCode.#objectValues[60]; + static Shekalim = ParshaCode.#objectValues[61]; + static Zachor = ParshaCode.#objectValues[62]; + static Parah = ParshaCode.#objectValues[63]; + static Hachodesh = ParshaCode.#objectValues[64]; + static Shuva = ParshaCode.#objectValues[65]; + static Shira = ParshaCode.#objectValues[66]; + static Hagadol = ParshaCode.#objectValues[67]; + static Chazon = ParshaCode.#objectValues[68]; + static Nachamu = ParshaCode.#objectValues[69]; + + + constructor(value) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/PirkeiAvosResult.d.ts b/interop/packages/typescript/lib/PirkeiAvosResult.d.ts new file mode 100644 index 0000000..7340475 --- /dev/null +++ b/interop/packages/typescript/lib/PirkeiAvosResult.d.ts @@ -0,0 +1,31 @@ +// generated by diplomat-tool +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + +export type PirkeiAvosResult_obj = { + kind: number; + perek1: number; + perek2: number; +}; + + + +/** + * Flat tagged union for Pirkei Avos (`kind`: 0 = single, 1 = combined). + */ +export class PirkeiAvosResult { + get kind(): number; + set kind(value: number); + get perek1(): number; + set perek1(value: number); + get perek2(): number; + set perek2(value: number); + /** @internal */ + static fromFields(structObj : PirkeiAvosResult_obj) : PirkeiAvosResult; + + /** + * Create `PirkeiAvosResult` from an object that contains all of `PirkeiAvosResult`s fields. + * Optional fields do not need to be included in the provided object. + */ + constructor(structObj: PirkeiAvosResult_obj); + +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/PirkeiAvosResult.mjs b/interop/packages/typescript/lib/PirkeiAvosResult.mjs new file mode 100644 index 0000000..50248e3 --- /dev/null +++ b/interop/packages/typescript/lib/PirkeiAvosResult.mjs @@ -0,0 +1,132 @@ +// generated by diplomat-tool +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +/** + * Flat tagged union for Pirkei Avos (`kind`: 0 = single, 1 = combined). + */ +export class PirkeiAvosResult { + #kind; + get kind() { + return this.#kind; + } + set kind(value){ + this.#kind = value; + } + #perek1; + get perek1() { + return this.#perek1; + } + set perek1(value){ + this.#perek1 = value; + } + #perek2; + get perek2() { + return this.#perek2; + } + set perek2(value){ + this.#perek2 = value; + } + /** @internal */ + static fromFields(structObj) { + return new PirkeiAvosResult(structObj); + } + + #internalConstructor(structObj) { + if (typeof structObj !== "object") { + throw new Error("PirkeiAvosResult's constructor takes an object of PirkeiAvosResult's fields."); + } + + if ("kind" in structObj) { + this.#kind = structObj.kind; + } else { + throw new Error("Missing required field kind."); + } + + if ("perek1" in structObj) { + this.#perek1 = structObj.perek1; + } else { + throw new Error("Missing required field perek1."); + } + + if ("perek2" in structObj) { + this.#perek2 = structObj.perek2; + } else { + throw new Error("Missing required field perek2."); + } + + return this; + } + + // Return this struct in FFI function friendly format. + // Returns an array that can be expanded with spread syntax (...) + _intoFFI( + dst, + functionCleanupArena, + appendArrayMap + ) { + + this._writeToArrayBuffer(wasm.memory.buffer, dst, functionCleanupArena, appendArrayMap); + + return dst; + } + + static get _sizeBytes() { + return 3; + } + + /// Currently unused, we may want to use later on though: + static get _sizeAlign() { + return 1; + } + + static _fromSuppliedValue(internalConstructor, obj) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("_fromSuppliedValue cannot be called externally."); + } + + if (obj instanceof PirkeiAvosResult) { + return obj; + } + + return PirkeiAvosResult.fromFields(obj); + } + + _writeToArrayBuffer( + arrayBuffer, + offset, + functionCleanupArena, + appendArrayMap + ) { + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#kind, Uint8Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 1, this.#perek1, Uint8Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 2, this.#perek2, Uint8Array); + } + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + static _fromFFI(internalConstructor, ptr) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("PirkeiAvosResult._fromFFI is not meant to be called externally. Please use the default constructor."); + } + let structObj = {}; + const kindDeref = (new Uint8Array(wasm.memory.buffer, ptr, 1))[0]; + structObj.kind = kindDeref; + const perek1Deref = (new Uint8Array(wasm.memory.buffer, ptr + 1, 1))[0]; + structObj.perek1 = perek1Deref; + const perek2Deref = (new Uint8Array(wasm.memory.buffer, ptr + 2, 1))[0]; + structObj.perek2 = perek2Deref; + + return new PirkeiAvosResult(structObj); + } + + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/SideCode.d.ts b/interop/packages/typescript/lib/SideCode.d.ts new file mode 100644 index 0000000..26f870b --- /dev/null +++ b/interop/packages/typescript/lib/SideCode.d.ts @@ -0,0 +1,21 @@ +// generated by diplomat-tool +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + + + +export class SideCode { + + /** @internal */ + static fromValue(value: SideCode | string): SideCode; + + get value(): string; + + /** @internal */ + get ffiValue(): number; + + static Aleph : SideCode; + static Bet : SideCode; + + + constructor(value: SideCode | string ); +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/SideCode.mjs b/interop/packages/typescript/lib/SideCode.mjs new file mode 100644 index 0000000..8e17557 --- /dev/null +++ b/interop/packages/typescript/lib/SideCode.mjs @@ -0,0 +1,69 @@ +// generated by diplomat-tool +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +export class SideCode { + #value = undefined; + + static #values = new Map([ + ["Aleph", 0], + ["Bet", 1] + ]); + + static getAllEntries() { + return SideCode.#values.entries(); + } + + #internalConstructor(value) { + if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { + // We pass in two internalConstructor arguments to create *new* + // instances of this type, otherwise the enums are treated as singletons. + if (arguments[1] === diplomatRuntime.internalConstructor ) { + this.#value = arguments[2]; + return this; + } + return SideCode.#objectValues[arguments[1]]; + } + + if (value instanceof SideCode) { + return value; + } + + let intVal = SideCode.#values.get(value); + + // Nullish check, checks for null or undefined + if (intVal != null) { + return SideCode.#objectValues[intVal]; + } + + throw TypeError(value + " is not a SideCode and does not correspond to any of its enumerator values."); + } + + /** @internal */ + static fromValue(value) { + return new SideCode(value); + } + + get value(){ + return [...SideCode.#values.keys()][this.#value]; + } + + /** @internal */ + get ffiValue(){ + return this.#value; + } + static #objectValues = [ + new SideCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), + new SideCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), + ]; + + static Aleph = SideCode.#objectValues[0]; + static Bet = SideCode.#objectValues[1]; + + + constructor(value) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/TehillimResult.d.ts b/interop/packages/typescript/lib/TehillimResult.d.ts new file mode 100644 index 0000000..2ca62c3 --- /dev/null +++ b/interop/packages/typescript/lib/TehillimResult.d.ts @@ -0,0 +1,40 @@ +// generated by diplomat-tool +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + +export type TehillimResult_obj = { + kind: number; + start: number; + end: number; + psalm: number; + startVerse: number; + endVerse: number; +}; + + + +/** + * Flat tagged union for Tehillim (`kind`: 0 = psalms range, 1 = verse range). + */ +export class TehillimResult { + get kind(): number; + set kind(value: number); + get start(): number; + set start(value: number); + get end(): number; + set end(value: number); + get psalm(): number; + set psalm(value: number); + get startVerse(): number; + set startVerse(value: number); + get endVerse(): number; + set endVerse(value: number); + /** @internal */ + static fromFields(structObj : TehillimResult_obj) : TehillimResult; + + /** + * Create `TehillimResult` from an object that contains all of `TehillimResult`s fields. + * Optional fields do not need to be included in the provided object. + */ + constructor(structObj: TehillimResult_obj); + +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/TehillimResult.mjs b/interop/packages/typescript/lib/TehillimResult.mjs new file mode 100644 index 0000000..25311d9 --- /dev/null +++ b/interop/packages/typescript/lib/TehillimResult.mjs @@ -0,0 +1,180 @@ +// generated by diplomat-tool +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +/** + * Flat tagged union for Tehillim (`kind`: 0 = psalms range, 1 = verse range). + */ +export class TehillimResult { + #kind; + get kind() { + return this.#kind; + } + set kind(value){ + this.#kind = value; + } + #start; + get start() { + return this.#start; + } + set start(value){ + this.#start = value; + } + #end; + get end() { + return this.#end; + } + set end(value){ + this.#end = value; + } + #psalm; + get psalm() { + return this.#psalm; + } + set psalm(value){ + this.#psalm = value; + } + #startVerse; + get startVerse() { + return this.#startVerse; + } + set startVerse(value){ + this.#startVerse = value; + } + #endVerse; + get endVerse() { + return this.#endVerse; + } + set endVerse(value){ + this.#endVerse = value; + } + /** @internal */ + static fromFields(structObj) { + return new TehillimResult(structObj); + } + + #internalConstructor(structObj) { + if (typeof structObj !== "object") { + throw new Error("TehillimResult's constructor takes an object of TehillimResult's fields."); + } + + if ("kind" in structObj) { + this.#kind = structObj.kind; + } else { + throw new Error("Missing required field kind."); + } + + if ("start" in structObj) { + this.#start = structObj.start; + } else { + throw new Error("Missing required field start."); + } + + if ("end" in structObj) { + this.#end = structObj.end; + } else { + throw new Error("Missing required field end."); + } + + if ("psalm" in structObj) { + this.#psalm = structObj.psalm; + } else { + throw new Error("Missing required field psalm."); + } + + if ("startVerse" in structObj) { + this.#startVerse = structObj.startVerse; + } else { + throw new Error("Missing required field startVerse."); + } + + if ("endVerse" in structObj) { + this.#endVerse = structObj.endVerse; + } else { + throw new Error("Missing required field endVerse."); + } + + return this; + } + + // Return this struct in FFI function friendly format. + // Returns an array that can be expanded with spread syntax (...) + _intoFFI( + dst, + functionCleanupArena, + appendArrayMap + ) { + + this._writeToArrayBuffer(wasm.memory.buffer, dst, functionCleanupArena, appendArrayMap); + + return dst; + } + + static get _sizeBytes() { + return 8; + } + + /// Currently unused, we may want to use later on though: + static get _sizeAlign() { + return 2; + } + + static _fromSuppliedValue(internalConstructor, obj) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("_fromSuppliedValue cannot be called externally."); + } + + if (obj instanceof TehillimResult) { + return obj; + } + + return TehillimResult.fromFields(obj); + } + + _writeToArrayBuffer( + arrayBuffer, + offset, + functionCleanupArena, + appendArrayMap + ) { + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#kind, Uint8Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 1, this.#start, Uint8Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 2, this.#end, Uint8Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 3, this.#psalm, Uint8Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 4, this.#startVerse, Uint16Array); + diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 6, this.#endVerse, Uint16Array); + } + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + static _fromFFI(internalConstructor, ptr) { + if (internalConstructor !== diplomatRuntime.internalConstructor) { + throw new Error("TehillimResult._fromFFI is not meant to be called externally. Please use the default constructor."); + } + let structObj = {}; + const kindDeref = (new Uint8Array(wasm.memory.buffer, ptr, 1))[0]; + structObj.kind = kindDeref; + const startDeref = (new Uint8Array(wasm.memory.buffer, ptr + 1, 1))[0]; + structObj.start = startDeref; + const endDeref = (new Uint8Array(wasm.memory.buffer, ptr + 2, 1))[0]; + structObj.end = endDeref; + const psalmDeref = (new Uint8Array(wasm.memory.buffer, ptr + 3, 1))[0]; + structObj.psalm = psalmDeref; + const startVerseDeref = (new Uint16Array(wasm.memory.buffer, ptr + 4, 1))[0]; + structObj.startVerse = startVerseDeref; + const endVerseDeref = (new Uint16Array(wasm.memory.buffer, ptr + 6, 1))[0]; + structObj.endVerse = endVerseDeref; + + return new TehillimResult(structObj); + } + + + constructor(structObj) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/TractateCode.d.ts b/interop/packages/typescript/lib/TractateCode.d.ts new file mode 100644 index 0000000..7159e0a --- /dev/null +++ b/interop/packages/typescript/lib/TractateCode.d.ts @@ -0,0 +1,82 @@ +// generated by diplomat-tool +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + + + +export class TractateCode { + + /** @internal */ + static fromValue(value: TractateCode | string): TractateCode; + + get value(): string; + + /** @internal */ + get ffiValue(): number; + + static Berachos : TractateCode; + static Peah : TractateCode; + static Demai : TractateCode; + static Kilayim : TractateCode; + static Sheviis : TractateCode; + static Terumos : TractateCode; + static Maasros : TractateCode; + static MaaserSheni : TractateCode; + static Chalah : TractateCode; + static Orlah : TractateCode; + static Bikurim : TractateCode; + static Shabbos : TractateCode; + static Eruvin : TractateCode; + static Pesachim : TractateCode; + static Shekalim : TractateCode; + static Yoma : TractateCode; + static Sukkah : TractateCode; + static Beitzah : TractateCode; + static RoshHashanah : TractateCode; + static Taanis : TractateCode; + static Megillah : TractateCode; + static MoedKatan : TractateCode; + static Chagigah : TractateCode; + static Yevamos : TractateCode; + static Kesubos : TractateCode; + static Nedarim : TractateCode; + static Nazir : TractateCode; + static Sotah : TractateCode; + static Gitin : TractateCode; + static Kiddushin : TractateCode; + static BavaKamma : TractateCode; + static BavaMetzia : TractateCode; + static BavaBasra : TractateCode; + static Sanhedrin : TractateCode; + static Makkos : TractateCode; + static Shevuos : TractateCode; + static Eduyos : TractateCode; + static AvodahZarah : TractateCode; + static Avos : TractateCode; + static Horiyos : TractateCode; + static Zevachim : TractateCode; + static Menachos : TractateCode; + static Chullin : TractateCode; + static Bechoros : TractateCode; + static Arachin : TractateCode; + static Temurah : TractateCode; + static Kerisos : TractateCode; + static Meilah : TractateCode; + static Tamid : TractateCode; + static Midos : TractateCode; + static Kinnim : TractateCode; + static Keilim : TractateCode; + static Ohalos : TractateCode; + static Negaim : TractateCode; + static Parah : TractateCode; + static Taharos : TractateCode; + static Mikvaos : TractateCode; + static Niddah : TractateCode; + static Machshirin : TractateCode; + static Zavim : TractateCode; + static TevulYom : TractateCode; + static Yadayim : TractateCode; + static Uktzin : TractateCode; + + + constructor(value: TractateCode | string ); +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/TractateCode.mjs b/interop/packages/typescript/lib/TractateCode.mjs new file mode 100644 index 0000000..96df458 --- /dev/null +++ b/interop/packages/typescript/lib/TractateCode.mjs @@ -0,0 +1,252 @@ +// generated by diplomat-tool +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +export class TractateCode { + #value = undefined; + + static #values = new Map([ + ["Berachos", 0], + ["Peah", 1], + ["Demai", 2], + ["Kilayim", 3], + ["Sheviis", 4], + ["Terumos", 5], + ["Maasros", 6], + ["MaaserSheni", 7], + ["Chalah", 8], + ["Orlah", 9], + ["Bikurim", 10], + ["Shabbos", 11], + ["Eruvin", 12], + ["Pesachim", 13], + ["Shekalim", 14], + ["Yoma", 15], + ["Sukkah", 16], + ["Beitzah", 17], + ["RoshHashanah", 18], + ["Taanis", 19], + ["Megillah", 20], + ["MoedKatan", 21], + ["Chagigah", 22], + ["Yevamos", 23], + ["Kesubos", 24], + ["Nedarim", 25], + ["Nazir", 26], + ["Sotah", 27], + ["Gitin", 28], + ["Kiddushin", 29], + ["BavaKamma", 30], + ["BavaMetzia", 31], + ["BavaBasra", 32], + ["Sanhedrin", 33], + ["Makkos", 34], + ["Shevuos", 35], + ["Eduyos", 36], + ["AvodahZarah", 37], + ["Avos", 38], + ["Horiyos", 39], + ["Zevachim", 40], + ["Menachos", 41], + ["Chullin", 42], + ["Bechoros", 43], + ["Arachin", 44], + ["Temurah", 45], + ["Kerisos", 46], + ["Meilah", 47], + ["Tamid", 48], + ["Midos", 49], + ["Kinnim", 50], + ["Keilim", 51], + ["Ohalos", 52], + ["Negaim", 53], + ["Parah", 54], + ["Taharos", 55], + ["Mikvaos", 56], + ["Niddah", 57], + ["Machshirin", 58], + ["Zavim", 59], + ["TevulYom", 60], + ["Yadayim", 61], + ["Uktzin", 62] + ]); + + static getAllEntries() { + return TractateCode.#values.entries(); + } + + #internalConstructor(value) { + if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { + // We pass in two internalConstructor arguments to create *new* + // instances of this type, otherwise the enums are treated as singletons. + if (arguments[1] === diplomatRuntime.internalConstructor ) { + this.#value = arguments[2]; + return this; + } + return TractateCode.#objectValues[arguments[1]]; + } + + if (value instanceof TractateCode) { + return value; + } + + let intVal = TractateCode.#values.get(value); + + // Nullish check, checks for null or undefined + if (intVal != null) { + return TractateCode.#objectValues[intVal]; + } + + throw TypeError(value + " is not a TractateCode and does not correspond to any of its enumerator values."); + } + + /** @internal */ + static fromValue(value) { + return new TractateCode(value); + } + + get value(){ + return [...TractateCode.#values.keys()][this.#value]; + } + + /** @internal */ + get ffiValue(){ + return this.#value; + } + static #objectValues = [ + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 6), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 7), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 8), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 9), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 10), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 11), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 12), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 13), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 14), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 15), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 16), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 17), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 18), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 19), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 20), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 21), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 22), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 23), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 24), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 25), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 26), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 27), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 28), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 29), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 30), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 31), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 32), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 33), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 34), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 35), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 36), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 37), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 38), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 39), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 40), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 41), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 42), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 43), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 44), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 45), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 46), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 47), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 48), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 49), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 50), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 51), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 52), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 53), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 54), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 55), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 56), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 57), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 58), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 59), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 60), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 61), + new TractateCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 62), + ]; + + static Berachos = TractateCode.#objectValues[0]; + static Peah = TractateCode.#objectValues[1]; + static Demai = TractateCode.#objectValues[2]; + static Kilayim = TractateCode.#objectValues[3]; + static Sheviis = TractateCode.#objectValues[4]; + static Terumos = TractateCode.#objectValues[5]; + static Maasros = TractateCode.#objectValues[6]; + static MaaserSheni = TractateCode.#objectValues[7]; + static Chalah = TractateCode.#objectValues[8]; + static Orlah = TractateCode.#objectValues[9]; + static Bikurim = TractateCode.#objectValues[10]; + static Shabbos = TractateCode.#objectValues[11]; + static Eruvin = TractateCode.#objectValues[12]; + static Pesachim = TractateCode.#objectValues[13]; + static Shekalim = TractateCode.#objectValues[14]; + static Yoma = TractateCode.#objectValues[15]; + static Sukkah = TractateCode.#objectValues[16]; + static Beitzah = TractateCode.#objectValues[17]; + static RoshHashanah = TractateCode.#objectValues[18]; + static Taanis = TractateCode.#objectValues[19]; + static Megillah = TractateCode.#objectValues[20]; + static MoedKatan = TractateCode.#objectValues[21]; + static Chagigah = TractateCode.#objectValues[22]; + static Yevamos = TractateCode.#objectValues[23]; + static Kesubos = TractateCode.#objectValues[24]; + static Nedarim = TractateCode.#objectValues[25]; + static Nazir = TractateCode.#objectValues[26]; + static Sotah = TractateCode.#objectValues[27]; + static Gitin = TractateCode.#objectValues[28]; + static Kiddushin = TractateCode.#objectValues[29]; + static BavaKamma = TractateCode.#objectValues[30]; + static BavaMetzia = TractateCode.#objectValues[31]; + static BavaBasra = TractateCode.#objectValues[32]; + static Sanhedrin = TractateCode.#objectValues[33]; + static Makkos = TractateCode.#objectValues[34]; + static Shevuos = TractateCode.#objectValues[35]; + static Eduyos = TractateCode.#objectValues[36]; + static AvodahZarah = TractateCode.#objectValues[37]; + static Avos = TractateCode.#objectValues[38]; + static Horiyos = TractateCode.#objectValues[39]; + static Zevachim = TractateCode.#objectValues[40]; + static Menachos = TractateCode.#objectValues[41]; + static Chullin = TractateCode.#objectValues[42]; + static Bechoros = TractateCode.#objectValues[43]; + static Arachin = TractateCode.#objectValues[44]; + static Temurah = TractateCode.#objectValues[45]; + static Kerisos = TractateCode.#objectValues[46]; + static Meilah = TractateCode.#objectValues[47]; + static Tamid = TractateCode.#objectValues[48]; + static Midos = TractateCode.#objectValues[49]; + static Kinnim = TractateCode.#objectValues[50]; + static Keilim = TractateCode.#objectValues[51]; + static Ohalos = TractateCode.#objectValues[52]; + static Negaim = TractateCode.#objectValues[53]; + static Parah = TractateCode.#objectValues[54]; + static Taharos = TractateCode.#objectValues[55]; + static Mikvaos = TractateCode.#objectValues[56]; + static Niddah = TractateCode.#objectValues[57]; + static Machshirin = TractateCode.#objectValues[58]; + static Zavim = TractateCode.#objectValues[59]; + static TevulYom = TractateCode.#objectValues[60]; + static Yadayim = TractateCode.#objectValues[61]; + static Uktzin = TractateCode.#objectValues[62]; + + + constructor(value) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/YearLengthTypeCode.d.ts b/interop/packages/typescript/lib/YearLengthTypeCode.d.ts new file mode 100644 index 0000000..fbae93c --- /dev/null +++ b/interop/packages/typescript/lib/YearLengthTypeCode.d.ts @@ -0,0 +1,22 @@ +// generated by diplomat-tool +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + + + +export class YearLengthTypeCode { + + /** @internal */ + static fromValue(value: YearLengthTypeCode | string): YearLengthTypeCode; + + get value(): string; + + /** @internal */ + get ffiValue(): number; + + static Chaserim : YearLengthTypeCode; + static Kesidran : YearLengthTypeCode; + static Shelaimim : YearLengthTypeCode; + + + constructor(value: YearLengthTypeCode | string ); +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/YearLengthTypeCode.mjs b/interop/packages/typescript/lib/YearLengthTypeCode.mjs new file mode 100644 index 0000000..2490dff --- /dev/null +++ b/interop/packages/typescript/lib/YearLengthTypeCode.mjs @@ -0,0 +1,72 @@ +// generated by diplomat-tool +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +export class YearLengthTypeCode { + #value = undefined; + + static #values = new Map([ + ["Chaserim", 0], + ["Kesidran", 1], + ["Shelaimim", 2] + ]); + + static getAllEntries() { + return YearLengthTypeCode.#values.entries(); + } + + #internalConstructor(value) { + if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { + // We pass in two internalConstructor arguments to create *new* + // instances of this type, otherwise the enums are treated as singletons. + if (arguments[1] === diplomatRuntime.internalConstructor ) { + this.#value = arguments[2]; + return this; + } + return YearLengthTypeCode.#objectValues[arguments[1]]; + } + + if (value instanceof YearLengthTypeCode) { + return value; + } + + let intVal = YearLengthTypeCode.#values.get(value); + + // Nullish check, checks for null or undefined + if (intVal != null) { + return YearLengthTypeCode.#objectValues[intVal]; + } + + throw TypeError(value + " is not a YearLengthTypeCode and does not correspond to any of its enumerator values."); + } + + /** @internal */ + static fromValue(value) { + return new YearLengthTypeCode(value); + } + + get value(){ + return [...YearLengthTypeCode.#values.keys()][this.#value]; + } + + /** @internal */ + get ffiValue(){ + return this.#value; + } + static #objectValues = [ + new YearLengthTypeCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), + new YearLengthTypeCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), + new YearLengthTypeCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), + ]; + + static Chaserim = YearLengthTypeCode.#objectValues[0]; + static Kesidran = YearLengthTypeCode.#objectValues[1]; + static Shelaimim = YearLengthTypeCode.#objectValues[2]; + + + constructor(value) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/ZmanPresetId.d.ts b/interop/packages/typescript/lib/ZmanPresetId.d.ts new file mode 100644 index 0000000..6ff315a --- /dev/null +++ b/interop/packages/typescript/lib/ZmanPresetId.d.ts @@ -0,0 +1,189 @@ +// generated by diplomat-tool +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + + + +/** + * Stable identifier for a generated zman preset. + */ +export class ZmanPresetId { + + /** @internal */ + static fromValue(value: ZmanPresetId | string): ZmanPresetId; + + get value(): string; + + /** @internal */ + get ffiValue(): number; + + static Alos120Minutes : ZmanPresetId; + static Alos120Zmanis : ZmanPresetId; + static Alos16Point1Degrees : ZmanPresetId; + static Alos18Degrees : ZmanPresetId; + static Alos19Degrees : ZmanPresetId; + static Alos19Point8Degrees : ZmanPresetId; + static Alos26Degrees : ZmanPresetId; + static Alos60Minutes : ZmanPresetId; + static Alos72Minutes : ZmanPresetId; + static Alos72Zmanis : ZmanPresetId; + static Alos90Minutes : ZmanPresetId; + static Alos90Zmanis : ZmanPresetId; + static Alos96Minutes : ZmanPresetId; + static Alos96Zmanis : ZmanPresetId; + static AlosBaalHatanya : ZmanPresetId; + static BainHashmashosRt13Point24Degrees : ZmanPresetId; + static BainHashmashosRt13Point5MinutesBefore7Point083Degrees : ZmanPresetId; + static BainHashmashosRt2Stars : ZmanPresetId; + static BainHashmashosRt58Point5Minutes : ZmanPresetId; + static BainHashmashosYereim13Point5Minutes : ZmanPresetId; + static BainHashmashosYereim16Point875Minutes : ZmanPresetId; + static BainHashmashosYereim18Minutes : ZmanPresetId; + static BainHashmashosYereim2Point1Degrees : ZmanPresetId; + static BainHashmashosYereim2Point8Degrees : ZmanPresetId; + static BainHashmashosYereim3Point05Degrees : ZmanPresetId; + static BeginAstronomicalTwilight : ZmanPresetId; + static BeginCivilTwilight : ZmanPresetId; + static BeginNauticalTwilight : ZmanPresetId; + static CandleLighting : ZmanPresetId; + static ChatzosHalayla : ZmanPresetId; + static ChatzosHayom : ZmanPresetId; + static ChatzosHayomAsHalfDay : ZmanPresetId; + static ElevationAdjustedSunrise : ZmanPresetId; + static ElevationAdjustedSunset : ZmanPresetId; + static EndAstronomicalTwilight : ZmanPresetId; + static EndCivilTwilight : ZmanPresetId; + static EndNauticalTwilight : ZmanPresetId; + static FixedLocalChatzosHayom : ZmanPresetId; + static MinchaGedola16Point1Degrees : ZmanPresetId; + static MinchaGedola30Minutes : ZmanPresetId; + static MinchaGedola72Minutes : ZmanPresetId; + static MinchaGedolaAhavatShalom : ZmanPresetId; + static MinchaGedolaAteretTorah : ZmanPresetId; + static MinchaGedolaBaalHatanya : ZmanPresetId; + static MinchaGedolaGra : ZmanPresetId; + static MinchaGedolaGrafixedLocalChatzos30Minutes : ZmanPresetId; + static MinchaGedolaGragreaterThan30 : ZmanPresetId; + static MinchaKetana16Point1Degrees : ZmanPresetId; + static MinchaKetana72Minutes : ZmanPresetId; + static MinchaKetanaAhavatShalom : ZmanPresetId; + static MinchaKetanaAteretTorah : ZmanPresetId; + static MinchaKetanaBaalHatanya : ZmanPresetId; + static MinchaKetanaGra : ZmanPresetId; + static MinchaKetanaGrafixedLocalChatzosToSunset : ZmanPresetId; + static Misheyakir10Point2Degrees : ZmanPresetId; + static Misheyakir11Degrees : ZmanPresetId; + static Misheyakir11Point5Degrees : ZmanPresetId; + static Misheyakir12Point85Degrees : ZmanPresetId; + static Misheyakir7Point65Degrees : ZmanPresetId; + static Misheyakir9Point5Degrees : ZmanPresetId; + static PlagAhavatShalom : ZmanPresetId; + static PlagAlos16Point1DegreesToTzaisGeonim7Point083Degrees : ZmanPresetId; + static PlagAlosToSunset : ZmanPresetId; + static PlagHamincha120Minutes : ZmanPresetId; + static PlagHamincha120MinutesZmanis : ZmanPresetId; + static PlagHamincha16Point1Degrees : ZmanPresetId; + static PlagHamincha18Degrees : ZmanPresetId; + static PlagHamincha19Point8Degrees : ZmanPresetId; + static PlagHamincha26Degrees : ZmanPresetId; + static PlagHamincha60Minutes : ZmanPresetId; + static PlagHamincha72Minutes : ZmanPresetId; + static PlagHamincha72MinutesZmanis : ZmanPresetId; + static PlagHamincha90Minutes : ZmanPresetId; + static PlagHamincha90MinutesZmanis : ZmanPresetId; + static PlagHamincha96Minutes : ZmanPresetId; + static PlagHamincha96MinutesZmanis : ZmanPresetId; + static PlagHaminchaAteretTorah : ZmanPresetId; + static PlagHaminchaBaalHatanya : ZmanPresetId; + static PlagHaminchaGra : ZmanPresetId; + static PlagHaminchaGrafixedLocalChatzosToSunset : ZmanPresetId; + static PolarSunriseBenIshChai : ZmanPresetId; + static PolarSunsetBenIshChai : ZmanPresetId; + static SamuchLeMinchaKetana16Point1Degrees : ZmanPresetId; + static SamuchLeMinchaKetana72Minutes : ZmanPresetId; + static SamuchLeMinchaKetanaGra : ZmanPresetId; + static SeaLevelSunrise : ZmanPresetId; + static SeaLevelSunset : ZmanPresetId; + static SofZmanAchilasChametzBaalHatanya : ZmanPresetId; + static SofZmanAchilasChametzGra : ZmanPresetId; + static SofZmanAchilasChametzMga16Point1Degrees : ZmanPresetId; + static SofZmanAchilasChametzMga72Minutes : ZmanPresetId; + static SofZmanAchilasChametzMga72MinutesZmanis : ZmanPresetId; + static SofZmanBiurChametzBaalHatanya : ZmanPresetId; + static SofZmanBiurChametzGra : ZmanPresetId; + static SofZmanBiurChametzMga16Point1Degrees : ZmanPresetId; + static SofZmanBiurChametzMga72Minutes : ZmanPresetId; + static SofZmanBiurChametzMga72MinutesZmanis : ZmanPresetId; + static SofZmanKidushLevana15Days : ZmanPresetId; + static SofZmanKidushLevanaBetweenMoldos : ZmanPresetId; + static SofZmanShma3HoursBeforeChatzos : ZmanPresetId; + static SofZmanShmaAlos16Point1DegreesToTzaisGeonim7Point083Degrees : ZmanPresetId; + static SofZmanShmaAlos16Point1ToSunset : ZmanPresetId; + static SofZmanShmaAteretTorah : ZmanPresetId; + static SofZmanShmaBaalHatanya : ZmanPresetId; + static SofZmanShmaGra : ZmanPresetId; + static SofZmanShmaGrasunriseToFixedLocalChatzos : ZmanPresetId; + static SofZmanShmaMga120Minutes : ZmanPresetId; + static SofZmanShmaMga16Point1Degrees : ZmanPresetId; + static SofZmanShmaMga16Point1DegreesToFixedLocalChatzos : ZmanPresetId; + static SofZmanShmaMga18Degrees : ZmanPresetId; + static SofZmanShmaMga18DegreesToFixedLocalChatzos : ZmanPresetId; + static SofZmanShmaMga19Point8Degrees : ZmanPresetId; + static SofZmanShmaMga72Minutes : ZmanPresetId; + static SofZmanShmaMga72MinutesToFixedLocalChatzos : ZmanPresetId; + static SofZmanShmaMga72MinutesZmanis : ZmanPresetId; + static SofZmanShmaMga90Minutes : ZmanPresetId; + static SofZmanShmaMga90MinutesToFixedLocalChatzos : ZmanPresetId; + static SofZmanShmaMga90MinutesZmanis : ZmanPresetId; + static SofZmanShmaMga96Minutes : ZmanPresetId; + static SofZmanShmaMga96MinutesZmanis : ZmanPresetId; + static SofZmanTfila2HoursBeforeChatzos : ZmanPresetId; + static SofZmanTfilaAteretTorah : ZmanPresetId; + static SofZmanTfilaBaalHatanya : ZmanPresetId; + static SofZmanTfilaGra : ZmanPresetId; + static SofZmanTfilaGrasunriseToFixedLocalChatzos : ZmanPresetId; + static SofZmanTfilaMga120Minutes : ZmanPresetId; + static SofZmanTfilaMga16Point1Degrees : ZmanPresetId; + static SofZmanTfilaMga18Degrees : ZmanPresetId; + static SofZmanTfilaMga19Point8Degrees : ZmanPresetId; + static SofZmanTfilaMga72Minutes : ZmanPresetId; + static SofZmanTfilaMga72MinutesZmanis : ZmanPresetId; + static SofZmanTfilaMga90Minutes : ZmanPresetId; + static SofZmanTfilaMga90MinutesZmanis : ZmanPresetId; + static SofZmanTfilaMga96Minutes : ZmanPresetId; + static SofZmanTfilaMga96MinutesZmanis : ZmanPresetId; + static SolarMidnight : ZmanPresetId; + static SunTransit : ZmanPresetId; + static TchilasZmanKidushLevana3Days : ZmanPresetId; + static TchilasZmanKidushLevana7Days : ZmanPresetId; + static Tzais120Minutes : ZmanPresetId; + static Tzais120Zmanis : ZmanPresetId; + static Tzais16Point1Degrees : ZmanPresetId; + static Tzais18Degrees : ZmanPresetId; + static Tzais19Point8Degrees : ZmanPresetId; + static Tzais26Degrees : ZmanPresetId; + static Tzais50Minutes : ZmanPresetId; + static Tzais60Minutes : ZmanPresetId; + static Tzais72Minutes : ZmanPresetId; + static Tzais72Zmanis : ZmanPresetId; + static Tzais90Minutes : ZmanPresetId; + static Tzais90Zmanis : ZmanPresetId; + static Tzais96Minutes : ZmanPresetId; + static Tzais96Zmanis : ZmanPresetId; + static TzaisAteretTorah : ZmanPresetId; + static TzaisBaalHatanya : ZmanPresetId; + static TzaisGeonim3Point7Degrees : ZmanPresetId; + static TzaisGeonim3Point8Degrees : ZmanPresetId; + static TzaisGeonim4Point42Degrees : ZmanPresetId; + static TzaisGeonim4Point66Degrees : ZmanPresetId; + static TzaisGeonim4Point8Degrees : ZmanPresetId; + static TzaisGeonim5Point95Degrees : ZmanPresetId; + static TzaisGeonim6Point45Degrees : ZmanPresetId; + static TzaisGeonim7Point083Degrees : ZmanPresetId; + static TzaisGeonim7Point67Degrees : ZmanPresetId; + static TzaisGeonim8Point5Degrees : ZmanPresetId; + static TzaisGeonim9Point3Degrees : ZmanPresetId; + static TzaisGeonim9Point75Degrees : ZmanPresetId; + + + constructor(value: ZmanPresetId | string ); +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/ZmanPresetId.mjs b/interop/packages/typescript/lib/ZmanPresetId.mjs new file mode 100644 index 0000000..0282bc6 --- /dev/null +++ b/interop/packages/typescript/lib/ZmanPresetId.mjs @@ -0,0 +1,567 @@ +// generated by diplomat-tool +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +/** + * Stable identifier for a generated zman preset. + */ +export class ZmanPresetId { + #value = undefined; + + static #values = new Map([ + ["Alos120Minutes", 0], + ["Alos120Zmanis", 1], + ["Alos16Point1Degrees", 2], + ["Alos18Degrees", 3], + ["Alos19Degrees", 4], + ["Alos19Point8Degrees", 5], + ["Alos26Degrees", 6], + ["Alos60Minutes", 7], + ["Alos72Minutes", 8], + ["Alos72Zmanis", 9], + ["Alos90Minutes", 10], + ["Alos90Zmanis", 11], + ["Alos96Minutes", 12], + ["Alos96Zmanis", 13], + ["AlosBaalHatanya", 14], + ["BainHashmashosRt13Point24Degrees", 15], + ["BainHashmashosRt13Point5MinutesBefore7Point083Degrees", 16], + ["BainHashmashosRt2Stars", 17], + ["BainHashmashosRt58Point5Minutes", 18], + ["BainHashmashosYereim13Point5Minutes", 19], + ["BainHashmashosYereim16Point875Minutes", 20], + ["BainHashmashosYereim18Minutes", 21], + ["BainHashmashosYereim2Point1Degrees", 22], + ["BainHashmashosYereim2Point8Degrees", 23], + ["BainHashmashosYereim3Point05Degrees", 24], + ["BeginAstronomicalTwilight", 25], + ["BeginCivilTwilight", 26], + ["BeginNauticalTwilight", 27], + ["CandleLighting", 28], + ["ChatzosHalayla", 29], + ["ChatzosHayom", 30], + ["ChatzosHayomAsHalfDay", 31], + ["ElevationAdjustedSunrise", 32], + ["ElevationAdjustedSunset", 33], + ["EndAstronomicalTwilight", 34], + ["EndCivilTwilight", 35], + ["EndNauticalTwilight", 36], + ["FixedLocalChatzosHayom", 37], + ["MinchaGedola16Point1Degrees", 38], + ["MinchaGedola30Minutes", 39], + ["MinchaGedola72Minutes", 40], + ["MinchaGedolaAhavatShalom", 41], + ["MinchaGedolaAteretTorah", 42], + ["MinchaGedolaBaalHatanya", 43], + ["MinchaGedolaGra", 44], + ["MinchaGedolaGrafixedLocalChatzos30Minutes", 45], + ["MinchaGedolaGragreaterThan30", 46], + ["MinchaKetana16Point1Degrees", 47], + ["MinchaKetana72Minutes", 48], + ["MinchaKetanaAhavatShalom", 49], + ["MinchaKetanaAteretTorah", 50], + ["MinchaKetanaBaalHatanya", 51], + ["MinchaKetanaGra", 52], + ["MinchaKetanaGrafixedLocalChatzosToSunset", 53], + ["Misheyakir10Point2Degrees", 54], + ["Misheyakir11Degrees", 55], + ["Misheyakir11Point5Degrees", 56], + ["Misheyakir12Point85Degrees", 57], + ["Misheyakir7Point65Degrees", 58], + ["Misheyakir9Point5Degrees", 59], + ["PlagAhavatShalom", 60], + ["PlagAlos16Point1DegreesToTzaisGeonim7Point083Degrees", 61], + ["PlagAlosToSunset", 62], + ["PlagHamincha120Minutes", 63], + ["PlagHamincha120MinutesZmanis", 64], + ["PlagHamincha16Point1Degrees", 65], + ["PlagHamincha18Degrees", 66], + ["PlagHamincha19Point8Degrees", 67], + ["PlagHamincha26Degrees", 68], + ["PlagHamincha60Minutes", 69], + ["PlagHamincha72Minutes", 70], + ["PlagHamincha72MinutesZmanis", 71], + ["PlagHamincha90Minutes", 72], + ["PlagHamincha90MinutesZmanis", 73], + ["PlagHamincha96Minutes", 74], + ["PlagHamincha96MinutesZmanis", 75], + ["PlagHaminchaAteretTorah", 76], + ["PlagHaminchaBaalHatanya", 77], + ["PlagHaminchaGra", 78], + ["PlagHaminchaGrafixedLocalChatzosToSunset", 79], + ["PolarSunriseBenIshChai", 80], + ["PolarSunsetBenIshChai", 81], + ["SamuchLeMinchaKetana16Point1Degrees", 82], + ["SamuchLeMinchaKetana72Minutes", 83], + ["SamuchLeMinchaKetanaGra", 84], + ["SeaLevelSunrise", 85], + ["SeaLevelSunset", 86], + ["SofZmanAchilasChametzBaalHatanya", 87], + ["SofZmanAchilasChametzGra", 88], + ["SofZmanAchilasChametzMga16Point1Degrees", 89], + ["SofZmanAchilasChametzMga72Minutes", 90], + ["SofZmanAchilasChametzMga72MinutesZmanis", 91], + ["SofZmanBiurChametzBaalHatanya", 92], + ["SofZmanBiurChametzGra", 93], + ["SofZmanBiurChametzMga16Point1Degrees", 94], + ["SofZmanBiurChametzMga72Minutes", 95], + ["SofZmanBiurChametzMga72MinutesZmanis", 96], + ["SofZmanKidushLevana15Days", 97], + ["SofZmanKidushLevanaBetweenMoldos", 98], + ["SofZmanShma3HoursBeforeChatzos", 99], + ["SofZmanShmaAlos16Point1DegreesToTzaisGeonim7Point083Degrees", 100], + ["SofZmanShmaAlos16Point1ToSunset", 101], + ["SofZmanShmaAteretTorah", 102], + ["SofZmanShmaBaalHatanya", 103], + ["SofZmanShmaGra", 104], + ["SofZmanShmaGrasunriseToFixedLocalChatzos", 105], + ["SofZmanShmaMga120Minutes", 106], + ["SofZmanShmaMga16Point1Degrees", 107], + ["SofZmanShmaMga16Point1DegreesToFixedLocalChatzos", 108], + ["SofZmanShmaMga18Degrees", 109], + ["SofZmanShmaMga18DegreesToFixedLocalChatzos", 110], + ["SofZmanShmaMga19Point8Degrees", 111], + ["SofZmanShmaMga72Minutes", 112], + ["SofZmanShmaMga72MinutesToFixedLocalChatzos", 113], + ["SofZmanShmaMga72MinutesZmanis", 114], + ["SofZmanShmaMga90Minutes", 115], + ["SofZmanShmaMga90MinutesToFixedLocalChatzos", 116], + ["SofZmanShmaMga90MinutesZmanis", 117], + ["SofZmanShmaMga96Minutes", 118], + ["SofZmanShmaMga96MinutesZmanis", 119], + ["SofZmanTfila2HoursBeforeChatzos", 120], + ["SofZmanTfilaAteretTorah", 121], + ["SofZmanTfilaBaalHatanya", 122], + ["SofZmanTfilaGra", 123], + ["SofZmanTfilaGrasunriseToFixedLocalChatzos", 124], + ["SofZmanTfilaMga120Minutes", 125], + ["SofZmanTfilaMga16Point1Degrees", 126], + ["SofZmanTfilaMga18Degrees", 127], + ["SofZmanTfilaMga19Point8Degrees", 128], + ["SofZmanTfilaMga72Minutes", 129], + ["SofZmanTfilaMga72MinutesZmanis", 130], + ["SofZmanTfilaMga90Minutes", 131], + ["SofZmanTfilaMga90MinutesZmanis", 132], + ["SofZmanTfilaMga96Minutes", 133], + ["SofZmanTfilaMga96MinutesZmanis", 134], + ["SolarMidnight", 135], + ["SunTransit", 136], + ["TchilasZmanKidushLevana3Days", 137], + ["TchilasZmanKidushLevana7Days", 138], + ["Tzais120Minutes", 139], + ["Tzais120Zmanis", 140], + ["Tzais16Point1Degrees", 141], + ["Tzais18Degrees", 142], + ["Tzais19Point8Degrees", 143], + ["Tzais26Degrees", 144], + ["Tzais50Minutes", 145], + ["Tzais60Minutes", 146], + ["Tzais72Minutes", 147], + ["Tzais72Zmanis", 148], + ["Tzais90Minutes", 149], + ["Tzais90Zmanis", 150], + ["Tzais96Minutes", 151], + ["Tzais96Zmanis", 152], + ["TzaisAteretTorah", 153], + ["TzaisBaalHatanya", 154], + ["TzaisGeonim3Point7Degrees", 155], + ["TzaisGeonim3Point8Degrees", 156], + ["TzaisGeonim4Point42Degrees", 157], + ["TzaisGeonim4Point66Degrees", 158], + ["TzaisGeonim4Point8Degrees", 159], + ["TzaisGeonim5Point95Degrees", 160], + ["TzaisGeonim6Point45Degrees", 161], + ["TzaisGeonim7Point083Degrees", 162], + ["TzaisGeonim7Point67Degrees", 163], + ["TzaisGeonim8Point5Degrees", 164], + ["TzaisGeonim9Point3Degrees", 165], + ["TzaisGeonim9Point75Degrees", 166] + ]); + + static getAllEntries() { + return ZmanPresetId.#values.entries(); + } + + #internalConstructor(value) { + if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { + // We pass in two internalConstructor arguments to create *new* + // instances of this type, otherwise the enums are treated as singletons. + if (arguments[1] === diplomatRuntime.internalConstructor ) { + this.#value = arguments[2]; + return this; + } + return ZmanPresetId.#objectValues[arguments[1]]; + } + + if (value instanceof ZmanPresetId) { + return value; + } + + let intVal = ZmanPresetId.#values.get(value); + + // Nullish check, checks for null or undefined + if (intVal != null) { + return ZmanPresetId.#objectValues[intVal]; + } + + throw TypeError(value + " is not a ZmanPresetId and does not correspond to any of its enumerator values."); + } + + /** @internal */ + static fromValue(value) { + return new ZmanPresetId(value); + } + + get value(){ + return [...ZmanPresetId.#values.keys()][this.#value]; + } + + /** @internal */ + get ffiValue(){ + return this.#value; + } + static #objectValues = [ + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 6), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 7), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 8), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 9), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 10), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 11), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 12), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 13), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 14), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 15), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 16), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 17), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 18), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 19), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 20), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 21), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 22), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 23), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 24), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 25), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 26), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 27), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 28), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 29), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 30), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 31), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 32), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 33), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 34), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 35), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 36), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 37), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 38), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 39), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 40), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 41), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 42), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 43), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 44), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 45), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 46), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 47), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 48), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 49), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 50), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 51), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 52), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 53), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 54), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 55), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 56), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 57), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 58), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 59), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 60), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 61), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 62), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 63), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 64), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 65), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 66), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 67), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 68), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 69), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 70), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 71), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 72), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 73), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 74), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 75), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 76), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 77), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 78), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 79), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 80), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 81), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 82), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 83), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 84), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 85), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 86), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 87), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 88), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 89), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 90), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 91), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 92), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 93), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 94), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 95), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 96), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 97), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 98), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 99), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 100), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 101), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 102), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 103), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 104), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 105), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 106), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 107), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 108), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 109), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 110), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 111), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 112), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 113), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 114), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 115), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 116), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 117), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 118), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 119), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 120), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 121), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 122), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 123), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 124), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 125), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 126), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 127), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 128), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 129), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 130), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 131), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 132), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 133), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 134), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 135), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 136), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 137), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 138), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 139), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 140), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 141), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 142), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 143), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 144), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 145), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 146), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 147), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 148), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 149), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 150), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 151), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 152), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 153), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 154), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 155), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 156), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 157), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 158), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 159), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 160), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 161), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 162), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 163), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 164), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 165), + new ZmanPresetId(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 166), + ]; + + static Alos120Minutes = ZmanPresetId.#objectValues[0]; + static Alos120Zmanis = ZmanPresetId.#objectValues[1]; + static Alos16Point1Degrees = ZmanPresetId.#objectValues[2]; + static Alos18Degrees = ZmanPresetId.#objectValues[3]; + static Alos19Degrees = ZmanPresetId.#objectValues[4]; + static Alos19Point8Degrees = ZmanPresetId.#objectValues[5]; + static Alos26Degrees = ZmanPresetId.#objectValues[6]; + static Alos60Minutes = ZmanPresetId.#objectValues[7]; + static Alos72Minutes = ZmanPresetId.#objectValues[8]; + static Alos72Zmanis = ZmanPresetId.#objectValues[9]; + static Alos90Minutes = ZmanPresetId.#objectValues[10]; + static Alos90Zmanis = ZmanPresetId.#objectValues[11]; + static Alos96Minutes = ZmanPresetId.#objectValues[12]; + static Alos96Zmanis = ZmanPresetId.#objectValues[13]; + static AlosBaalHatanya = ZmanPresetId.#objectValues[14]; + static BainHashmashosRt13Point24Degrees = ZmanPresetId.#objectValues[15]; + static BainHashmashosRt13Point5MinutesBefore7Point083Degrees = ZmanPresetId.#objectValues[16]; + static BainHashmashosRt2Stars = ZmanPresetId.#objectValues[17]; + static BainHashmashosRt58Point5Minutes = ZmanPresetId.#objectValues[18]; + static BainHashmashosYereim13Point5Minutes = ZmanPresetId.#objectValues[19]; + static BainHashmashosYereim16Point875Minutes = ZmanPresetId.#objectValues[20]; + static BainHashmashosYereim18Minutes = ZmanPresetId.#objectValues[21]; + static BainHashmashosYereim2Point1Degrees = ZmanPresetId.#objectValues[22]; + static BainHashmashosYereim2Point8Degrees = ZmanPresetId.#objectValues[23]; + static BainHashmashosYereim3Point05Degrees = ZmanPresetId.#objectValues[24]; + static BeginAstronomicalTwilight = ZmanPresetId.#objectValues[25]; + static BeginCivilTwilight = ZmanPresetId.#objectValues[26]; + static BeginNauticalTwilight = ZmanPresetId.#objectValues[27]; + static CandleLighting = ZmanPresetId.#objectValues[28]; + static ChatzosHalayla = ZmanPresetId.#objectValues[29]; + static ChatzosHayom = ZmanPresetId.#objectValues[30]; + static ChatzosHayomAsHalfDay = ZmanPresetId.#objectValues[31]; + static ElevationAdjustedSunrise = ZmanPresetId.#objectValues[32]; + static ElevationAdjustedSunset = ZmanPresetId.#objectValues[33]; + static EndAstronomicalTwilight = ZmanPresetId.#objectValues[34]; + static EndCivilTwilight = ZmanPresetId.#objectValues[35]; + static EndNauticalTwilight = ZmanPresetId.#objectValues[36]; + static FixedLocalChatzosHayom = ZmanPresetId.#objectValues[37]; + static MinchaGedola16Point1Degrees = ZmanPresetId.#objectValues[38]; + static MinchaGedola30Minutes = ZmanPresetId.#objectValues[39]; + static MinchaGedola72Minutes = ZmanPresetId.#objectValues[40]; + static MinchaGedolaAhavatShalom = ZmanPresetId.#objectValues[41]; + static MinchaGedolaAteretTorah = ZmanPresetId.#objectValues[42]; + static MinchaGedolaBaalHatanya = ZmanPresetId.#objectValues[43]; + static MinchaGedolaGra = ZmanPresetId.#objectValues[44]; + static MinchaGedolaGrafixedLocalChatzos30Minutes = ZmanPresetId.#objectValues[45]; + static MinchaGedolaGragreaterThan30 = ZmanPresetId.#objectValues[46]; + static MinchaKetana16Point1Degrees = ZmanPresetId.#objectValues[47]; + static MinchaKetana72Minutes = ZmanPresetId.#objectValues[48]; + static MinchaKetanaAhavatShalom = ZmanPresetId.#objectValues[49]; + static MinchaKetanaAteretTorah = ZmanPresetId.#objectValues[50]; + static MinchaKetanaBaalHatanya = ZmanPresetId.#objectValues[51]; + static MinchaKetanaGra = ZmanPresetId.#objectValues[52]; + static MinchaKetanaGrafixedLocalChatzosToSunset = ZmanPresetId.#objectValues[53]; + static Misheyakir10Point2Degrees = ZmanPresetId.#objectValues[54]; + static Misheyakir11Degrees = ZmanPresetId.#objectValues[55]; + static Misheyakir11Point5Degrees = ZmanPresetId.#objectValues[56]; + static Misheyakir12Point85Degrees = ZmanPresetId.#objectValues[57]; + static Misheyakir7Point65Degrees = ZmanPresetId.#objectValues[58]; + static Misheyakir9Point5Degrees = ZmanPresetId.#objectValues[59]; + static PlagAhavatShalom = ZmanPresetId.#objectValues[60]; + static PlagAlos16Point1DegreesToTzaisGeonim7Point083Degrees = ZmanPresetId.#objectValues[61]; + static PlagAlosToSunset = ZmanPresetId.#objectValues[62]; + static PlagHamincha120Minutes = ZmanPresetId.#objectValues[63]; + static PlagHamincha120MinutesZmanis = ZmanPresetId.#objectValues[64]; + static PlagHamincha16Point1Degrees = ZmanPresetId.#objectValues[65]; + static PlagHamincha18Degrees = ZmanPresetId.#objectValues[66]; + static PlagHamincha19Point8Degrees = ZmanPresetId.#objectValues[67]; + static PlagHamincha26Degrees = ZmanPresetId.#objectValues[68]; + static PlagHamincha60Minutes = ZmanPresetId.#objectValues[69]; + static PlagHamincha72Minutes = ZmanPresetId.#objectValues[70]; + static PlagHamincha72MinutesZmanis = ZmanPresetId.#objectValues[71]; + static PlagHamincha90Minutes = ZmanPresetId.#objectValues[72]; + static PlagHamincha90MinutesZmanis = ZmanPresetId.#objectValues[73]; + static PlagHamincha96Minutes = ZmanPresetId.#objectValues[74]; + static PlagHamincha96MinutesZmanis = ZmanPresetId.#objectValues[75]; + static PlagHaminchaAteretTorah = ZmanPresetId.#objectValues[76]; + static PlagHaminchaBaalHatanya = ZmanPresetId.#objectValues[77]; + static PlagHaminchaGra = ZmanPresetId.#objectValues[78]; + static PlagHaminchaGrafixedLocalChatzosToSunset = ZmanPresetId.#objectValues[79]; + static PolarSunriseBenIshChai = ZmanPresetId.#objectValues[80]; + static PolarSunsetBenIshChai = ZmanPresetId.#objectValues[81]; + static SamuchLeMinchaKetana16Point1Degrees = ZmanPresetId.#objectValues[82]; + static SamuchLeMinchaKetana72Minutes = ZmanPresetId.#objectValues[83]; + static SamuchLeMinchaKetanaGra = ZmanPresetId.#objectValues[84]; + static SeaLevelSunrise = ZmanPresetId.#objectValues[85]; + static SeaLevelSunset = ZmanPresetId.#objectValues[86]; + static SofZmanAchilasChametzBaalHatanya = ZmanPresetId.#objectValues[87]; + static SofZmanAchilasChametzGra = ZmanPresetId.#objectValues[88]; + static SofZmanAchilasChametzMga16Point1Degrees = ZmanPresetId.#objectValues[89]; + static SofZmanAchilasChametzMga72Minutes = ZmanPresetId.#objectValues[90]; + static SofZmanAchilasChametzMga72MinutesZmanis = ZmanPresetId.#objectValues[91]; + static SofZmanBiurChametzBaalHatanya = ZmanPresetId.#objectValues[92]; + static SofZmanBiurChametzGra = ZmanPresetId.#objectValues[93]; + static SofZmanBiurChametzMga16Point1Degrees = ZmanPresetId.#objectValues[94]; + static SofZmanBiurChametzMga72Minutes = ZmanPresetId.#objectValues[95]; + static SofZmanBiurChametzMga72MinutesZmanis = ZmanPresetId.#objectValues[96]; + static SofZmanKidushLevana15Days = ZmanPresetId.#objectValues[97]; + static SofZmanKidushLevanaBetweenMoldos = ZmanPresetId.#objectValues[98]; + static SofZmanShma3HoursBeforeChatzos = ZmanPresetId.#objectValues[99]; + static SofZmanShmaAlos16Point1DegreesToTzaisGeonim7Point083Degrees = ZmanPresetId.#objectValues[100]; + static SofZmanShmaAlos16Point1ToSunset = ZmanPresetId.#objectValues[101]; + static SofZmanShmaAteretTorah = ZmanPresetId.#objectValues[102]; + static SofZmanShmaBaalHatanya = ZmanPresetId.#objectValues[103]; + static SofZmanShmaGra = ZmanPresetId.#objectValues[104]; + static SofZmanShmaGrasunriseToFixedLocalChatzos = ZmanPresetId.#objectValues[105]; + static SofZmanShmaMga120Minutes = ZmanPresetId.#objectValues[106]; + static SofZmanShmaMga16Point1Degrees = ZmanPresetId.#objectValues[107]; + static SofZmanShmaMga16Point1DegreesToFixedLocalChatzos = ZmanPresetId.#objectValues[108]; + static SofZmanShmaMga18Degrees = ZmanPresetId.#objectValues[109]; + static SofZmanShmaMga18DegreesToFixedLocalChatzos = ZmanPresetId.#objectValues[110]; + static SofZmanShmaMga19Point8Degrees = ZmanPresetId.#objectValues[111]; + static SofZmanShmaMga72Minutes = ZmanPresetId.#objectValues[112]; + static SofZmanShmaMga72MinutesToFixedLocalChatzos = ZmanPresetId.#objectValues[113]; + static SofZmanShmaMga72MinutesZmanis = ZmanPresetId.#objectValues[114]; + static SofZmanShmaMga90Minutes = ZmanPresetId.#objectValues[115]; + static SofZmanShmaMga90MinutesToFixedLocalChatzos = ZmanPresetId.#objectValues[116]; + static SofZmanShmaMga90MinutesZmanis = ZmanPresetId.#objectValues[117]; + static SofZmanShmaMga96Minutes = ZmanPresetId.#objectValues[118]; + static SofZmanShmaMga96MinutesZmanis = ZmanPresetId.#objectValues[119]; + static SofZmanTfila2HoursBeforeChatzos = ZmanPresetId.#objectValues[120]; + static SofZmanTfilaAteretTorah = ZmanPresetId.#objectValues[121]; + static SofZmanTfilaBaalHatanya = ZmanPresetId.#objectValues[122]; + static SofZmanTfilaGra = ZmanPresetId.#objectValues[123]; + static SofZmanTfilaGrasunriseToFixedLocalChatzos = ZmanPresetId.#objectValues[124]; + static SofZmanTfilaMga120Minutes = ZmanPresetId.#objectValues[125]; + static SofZmanTfilaMga16Point1Degrees = ZmanPresetId.#objectValues[126]; + static SofZmanTfilaMga18Degrees = ZmanPresetId.#objectValues[127]; + static SofZmanTfilaMga19Point8Degrees = ZmanPresetId.#objectValues[128]; + static SofZmanTfilaMga72Minutes = ZmanPresetId.#objectValues[129]; + static SofZmanTfilaMga72MinutesZmanis = ZmanPresetId.#objectValues[130]; + static SofZmanTfilaMga90Minutes = ZmanPresetId.#objectValues[131]; + static SofZmanTfilaMga90MinutesZmanis = ZmanPresetId.#objectValues[132]; + static SofZmanTfilaMga96Minutes = ZmanPresetId.#objectValues[133]; + static SofZmanTfilaMga96MinutesZmanis = ZmanPresetId.#objectValues[134]; + static SolarMidnight = ZmanPresetId.#objectValues[135]; + static SunTransit = ZmanPresetId.#objectValues[136]; + static TchilasZmanKidushLevana3Days = ZmanPresetId.#objectValues[137]; + static TchilasZmanKidushLevana7Days = ZmanPresetId.#objectValues[138]; + static Tzais120Minutes = ZmanPresetId.#objectValues[139]; + static Tzais120Zmanis = ZmanPresetId.#objectValues[140]; + static Tzais16Point1Degrees = ZmanPresetId.#objectValues[141]; + static Tzais18Degrees = ZmanPresetId.#objectValues[142]; + static Tzais19Point8Degrees = ZmanPresetId.#objectValues[143]; + static Tzais26Degrees = ZmanPresetId.#objectValues[144]; + static Tzais50Minutes = ZmanPresetId.#objectValues[145]; + static Tzais60Minutes = ZmanPresetId.#objectValues[146]; + static Tzais72Minutes = ZmanPresetId.#objectValues[147]; + static Tzais72Zmanis = ZmanPresetId.#objectValues[148]; + static Tzais90Minutes = ZmanPresetId.#objectValues[149]; + static Tzais90Zmanis = ZmanPresetId.#objectValues[150]; + static Tzais96Minutes = ZmanPresetId.#objectValues[151]; + static Tzais96Zmanis = ZmanPresetId.#objectValues[152]; + static TzaisAteretTorah = ZmanPresetId.#objectValues[153]; + static TzaisBaalHatanya = ZmanPresetId.#objectValues[154]; + static TzaisGeonim3Point7Degrees = ZmanPresetId.#objectValues[155]; + static TzaisGeonim3Point8Degrees = ZmanPresetId.#objectValues[156]; + static TzaisGeonim4Point42Degrees = ZmanPresetId.#objectValues[157]; + static TzaisGeonim4Point66Degrees = ZmanPresetId.#objectValues[158]; + static TzaisGeonim4Point8Degrees = ZmanPresetId.#objectValues[159]; + static TzaisGeonim5Point95Degrees = ZmanPresetId.#objectValues[160]; + static TzaisGeonim6Point45Degrees = ZmanPresetId.#objectValues[161]; + static TzaisGeonim7Point083Degrees = ZmanPresetId.#objectValues[162]; + static TzaisGeonim7Point67Degrees = ZmanPresetId.#objectValues[163]; + static TzaisGeonim8Point5Degrees = ZmanPresetId.#objectValues[164]; + static TzaisGeonim9Point3Degrees = ZmanPresetId.#objectValues[165]; + static TzaisGeonim9Point75Degrees = ZmanPresetId.#objectValues[166]; + + + constructor(value) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/ZmanPresets.d.ts b/interop/packages/typescript/lib/ZmanPresets.d.ts new file mode 100644 index 0000000..d750999 --- /dev/null +++ b/interop/packages/typescript/lib/ZmanPresets.d.ts @@ -0,0 +1,24 @@ +// generated by diplomat-tool +import type { ZmanPresetId } from "./ZmanPresetId" +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + + + +/** + * Dart entry point: construct once and call instance methods. + */ +export class ZmanPresets { + /** @internal */ + get ffiValue(): pointer; + + + presetCount(): number; + + presetName(preset: ZmanPresetId): boolean; + + presetDeprecated(preset: ZmanPresetId): boolean; + + presetMethodName(preset: ZmanPresetId): boolean; + + constructor(); +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/ZmanPresets.mjs b/interop/packages/typescript/lib/ZmanPresets.mjs new file mode 100644 index 0000000..32bc30b --- /dev/null +++ b/interop/packages/typescript/lib/ZmanPresets.mjs @@ -0,0 +1,116 @@ +// generated by diplomat-tool +import { ZmanPresetId } from "./ZmanPresetId.mjs" +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + +const ZmanPresets_box_destroy_registry = new FinalizationRegistry((ptr) => { + wasm.ZmanPresets_destroy(ptr); +}); + +/** + * Dart entry point: construct once and call instance methods. + */ +export class ZmanPresets { + // Internal ptr reference: + #ptr = null; + + // Lifetimes are only to keep dependencies alive. + // Since JS won't garbage collect until there are no incoming edges. + #selfEdge = []; + + #internalConstructor(symbol, ptr, selfEdge) { + if (symbol !== diplomatRuntime.internalConstructor) { + console.error("ZmanPresets is an Opaque type. You cannot call its constructor."); + return; + } + this.#ptr = ptr; + this.#selfEdge = selfEdge; + + // Are we being borrowed? If not, we can register. + if (this.#selfEdge.length === 0) { + ZmanPresets_box_destroy_registry.register(this, this.#ptr); + } + + return this; + } + /** @internal */ + get ffiValue() { + return this.#ptr; + } + + + #defaultConstructor() { + + const result = wasm.ZmanPresets_new(); + + try { + return new ZmanPresets(diplomatRuntime.internalConstructor, result, []); + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + } + } + + presetCount() { + + const result = wasm.ZmanPresets_preset_count(this.ffiValue); + + try { + return result; + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + } + } + + presetName(preset) { + + const result = wasm.ZmanPresets_preset_name(this.ffiValue, preset.ffiValue); + + try { + return result; + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + } + } + + presetDeprecated(preset) { + + const result = wasm.ZmanPresets_preset_deprecated(this.ffiValue, preset.ffiValue); + + try { + return result; + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + } + } + + presetMethodName(preset) { + + const result = wasm.ZmanPresets_preset_method_name(this.ffiValue, preset.ffiValue); + + try { + return result; + } + + finally { + diplomatRuntime.FUNCTION_PARAM_ALLOC.clean(); + } + } + + constructor() { + if (arguments[0] === diplomatRuntime.exposeConstructor) { + return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1)); + } else if (arguments[0] === diplomatRuntime.internalConstructor) { + return this.#internalConstructor(...arguments); + } else { + return this.#defaultConstructor(...arguments); + } + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/ZmanimErrorCode.d.ts b/interop/packages/typescript/lib/ZmanimErrorCode.d.ts new file mode 100644 index 0000000..b3fdc43 --- /dev/null +++ b/interop/packages/typescript/lib/ZmanimErrorCode.d.ts @@ -0,0 +1,29 @@ +// generated by diplomat-tool +import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; + + + +export class ZmanimErrorCode { + + /** @internal */ + static fromValue(value: ZmanimErrorCode | string): ZmanimErrorCode; + + get value(): string; + + /** @internal */ + get ffiValue(): number; + + static InvalidLatitude : ZmanimErrorCode; + static InvalidLongitude : ZmanimErrorCode; + static InvalidElevation : ZmanimErrorCode; + static TimeZoneRequired : ZmanimErrorCode; + static CalculationError : ZmanimErrorCode; + static AllDay : ZmanimErrorCode; + static AllNight : ZmanimErrorCode; + static TimeConversionError : ZmanimErrorCode; + static InvalidForDate : ZmanimErrorCode; + static InvalidHours : ZmanimErrorCode; + + + constructor(value: ZmanimErrorCode | string ); +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/ZmanimErrorCode.mjs b/interop/packages/typescript/lib/ZmanimErrorCode.mjs new file mode 100644 index 0000000..25e9ee1 --- /dev/null +++ b/interop/packages/typescript/lib/ZmanimErrorCode.mjs @@ -0,0 +1,93 @@ +// generated by diplomat-tool +import wasm from "./diplomat-wasm.mjs"; +import * as diplomatRuntime from "./diplomat-runtime.mjs"; + + + +export class ZmanimErrorCode { + #value = undefined; + + static #values = new Map([ + ["InvalidLatitude", 0], + ["InvalidLongitude", 1], + ["InvalidElevation", 2], + ["TimeZoneRequired", 3], + ["CalculationError", 4], + ["AllDay", 5], + ["AllNight", 6], + ["TimeConversionError", 7], + ["InvalidForDate", 8], + ["InvalidHours", 9] + ]); + + static getAllEntries() { + return ZmanimErrorCode.#values.entries(); + } + + #internalConstructor(value) { + if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { + // We pass in two internalConstructor arguments to create *new* + // instances of this type, otherwise the enums are treated as singletons. + if (arguments[1] === diplomatRuntime.internalConstructor ) { + this.#value = arguments[2]; + return this; + } + return ZmanimErrorCode.#objectValues[arguments[1]]; + } + + if (value instanceof ZmanimErrorCode) { + return value; + } + + let intVal = ZmanimErrorCode.#values.get(value); + + // Nullish check, checks for null or undefined + if (intVal != null) { + return ZmanimErrorCode.#objectValues[intVal]; + } + + throw TypeError(value + " is not a ZmanimErrorCode and does not correspond to any of its enumerator values."); + } + + /** @internal */ + static fromValue(value) { + return new ZmanimErrorCode(value); + } + + get value(){ + return [...ZmanimErrorCode.#values.keys()][this.#value]; + } + + /** @internal */ + get ffiValue(){ + return this.#value; + } + static #objectValues = [ + new ZmanimErrorCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), + new ZmanimErrorCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), + new ZmanimErrorCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), + new ZmanimErrorCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3), + new ZmanimErrorCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4), + new ZmanimErrorCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5), + new ZmanimErrorCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 6), + new ZmanimErrorCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 7), + new ZmanimErrorCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 8), + new ZmanimErrorCode(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 9), + ]; + + static InvalidLatitude = ZmanimErrorCode.#objectValues[0]; + static InvalidLongitude = ZmanimErrorCode.#objectValues[1]; + static InvalidElevation = ZmanimErrorCode.#objectValues[2]; + static TimeZoneRequired = ZmanimErrorCode.#objectValues[3]; + static CalculationError = ZmanimErrorCode.#objectValues[4]; + static AllDay = ZmanimErrorCode.#objectValues[5]; + static AllNight = ZmanimErrorCode.#objectValues[6]; + static TimeConversionError = ZmanimErrorCode.#objectValues[7]; + static InvalidForDate = ZmanimErrorCode.#objectValues[8]; + static InvalidHours = ZmanimErrorCode.#objectValues[9]; + + + constructor(value) { + return this.#internalConstructor(...arguments) + } +} \ No newline at end of file diff --git a/interop/packages/typescript/lib/diplomat-runtime.d.ts b/interop/packages/typescript/lib/diplomat-runtime.d.ts new file mode 100644 index 0000000..800840e --- /dev/null +++ b/interop/packages/typescript/lib/diplomat-runtime.d.ts @@ -0,0 +1,15 @@ +/// A [codepoint] is a Unicode code point, such as `a`, or `💡`. +/// +/// The recommended way to obtain a `codepoint` is to create it from a +/// `String`, which is conceptually a list of `codepoint`s. For example, +/// `'a'.codePointAt(0)` is equal to the `char` `a`. +/// +/// JS does not have a character/codepoint literal, so integer literals +/// need to be used. For example the Unicode code point U+1F4A1, `💡`, +/// can be represented by `0x1F4A1`. Note that only values in the ranges +/// `0x0..0xD7FF` and `0xE000..0x10FFFF` (both inclusive) are Unicode +/// code points, and hence valid `codepoint`s. +/// +/// A `String` can be constructed from a `codepoint` using `String.fromCodePoint()`. +export type codepoint = number; +export type pointer = number; \ No newline at end of file diff --git a/interop/packages/typescript/lib/diplomat-runtime.mjs b/interop/packages/typescript/lib/diplomat-runtime.mjs new file mode 100644 index 0000000..10eec9b --- /dev/null +++ b/interop/packages/typescript/lib/diplomat-runtime.mjs @@ -0,0 +1,774 @@ +/** For internal Diplomat use when constructing opaques or out structs. + * This is for when we're handling items that we don't want the user to touch, like an structure that's only meant to be output, or de-referencing a pointer we're handed from WASM. + */ +export const internalConstructor = Symbol("constructor"); +/** For internal Diplomat use when accessing a from-fields/from-value constructor that's been overridden by a default constructor. + * If we want to pass in arguments without also passing in internalConstructor to avoid triggering some logic we don't want, we use exposeConstructor. + */ +export const exposeConstructor = Symbol("exposeConstructor"); + +export function readString8(wasm, ptr, len) { + const buf = new Uint8Array(wasm.memory.buffer, ptr, len); + return (new TextDecoder("utf-8")).decode(buf) +} + +export function readString16(wasm, ptr, len) { + const buf = new Uint16Array(wasm.memory.buffer, ptr, len); + return String.fromCharCode.apply(null, buf) +} + +export function withDiplomatWrite(wasm, callback) { + const write = wasm.diplomat_buffer_write_create(0); + try { + callback(write); + const outStringPtr = wasm.diplomat_buffer_write_get_bytes(write); + if (outStringPtr === null) { + throw Error("Out of memory"); + } + const outStringLen = wasm.diplomat_buffer_write_len(write); + return readString8(wasm, outStringPtr, outStringLen); + } finally { + wasm.diplomat_buffer_write_destroy(write); + } +} + +/** + * Get the pointer returned by an FFI function. + * + * It's tempting to call `(new Uint32Array(wasm.memory.buffer, FFI_func(), 1))[0]`. + * However, there's a chance that `wasm.memory.buffer` will be resized between + * the time it's accessed and the time it's used, invalidating the view. + * This function ensures that the view into wasm memory is fresh. + * + * This is used for methods that return multiple types into a wasm buffer, where + * one of those types is another ptr. Call this method to get access to the returned + * ptr, so the return buffer can be freed. + * @param {WebAssembly.Exports} wasm Provided by diplomat generated files. + * @param {number} ptr Pointer of a pointer, to be read. + * @returns {number} The underlying pointer. + */ +export function ptrRead(wasm, ptr) { + return (new Uint32Array(wasm.memory.buffer, ptr, 1))[0]; +} + +/** + * Get the flag of a result type. + */ +export function resultFlag(wasm, ptr, offset) { + return (new Uint8Array(wasm.memory.buffer, ptr + offset, 1))[0]; +} + +/** + * Get the discriminant of a Rust enum. +*/ +export function enumDiscriminant(wasm, ptr) { + return (new Int32Array(wasm.memory.buffer, ptr, 1))[0] +} + +/** + * Return an array of paddingCount zeroes to be spread into a function call + * if needsPaddingFields is true, else empty + */ +export function maybePaddingFields(needsPaddingFields, paddingCount) { + if (needsPaddingFields) { + return Array(paddingCount).fill(0); + } else { + return []; + } +} + +/** +* Write a value of width `width` to a an ArrayBuffer `arrayBuffer` +* at byte offset `offset`, treating it as a buffer of kind `typedArrayKind` +* (which is a `TypedArray` variant like `Uint8Array` or `Int16Array`) +*/ +export function writeToArrayBuffer(arrayBuffer, offset, value, typedArrayKind) { + let buffer = new typedArrayKind(arrayBuffer, offset); + buffer[0] = value; +} + +/** +* Take `jsValue` and write it to arrayBuffer at offset `offset` if it is non-null +* calling `writeToArrayBufferCallback(arrayBuffer, offset, jsValue)` to write to the buffer, +* also writing a tag bit. +* +* `size` and `align` are the size and alignment of T, not of Option +*/ +export function writeOptionToArrayBuffer(arrayBuffer, offset, jsValue, size, align, writeToArrayBufferCallback) { + // perform a nullish check, not a null check, + // we want identical behavior for undefined + if (jsValue != null) { + writeToArrayBufferCallback(arrayBuffer, offset, jsValue); + writeToArrayBuffer(arrayBuffer, offset + size, 1, Uint8Array); + } +} + +/** +* For Option of given size/align (of T, not the overall option type), +* return an array of fields suitable for passing down to a parameter list. +* +* Calls writeToArrayBufferCallback(arrayBuffer, offset, jsValue) for non-null jsValues +* +* This array will have size/align elements for the actual T, then one element +* for the is_ok bool. +* +* See wasm_abi_quirks.md's section on Unions for understanding this ABI. +*/ +export function optionToArgsForCalling(jsValue, size, align, writeToArrayBufferCallback) { + let args; + // perform a nullish check, not a null check, + // we want identical behavior for undefined + if (jsValue != null) { + let buffer; + // We need our originator array to be properly aligned + if (align == 8) { + buffer = new BigUint64Array(size / align); + } else if (align == 4) { + buffer = new Uint32Array(size / align); + } else if (align == 2) { + buffer = new Uint16Array(size / align); + } else { + buffer = new Uint8Array(size / align); + } + + + writeToArrayBufferCallback(buffer.buffer, 0, jsValue); + args = Array.from(buffer); + args.push(1); + } else { + args = Array(size / align).fill(0); + args.push(0); + } + + // Unconditionally add padding + args = args.concat(Array(align - 1).fill(0)); + return args; +} + +/** +* For Option of given size/align (of T, not the overall option type), +* return a pointer to wasm memory, allocated in `allocator`, that stores a `jsValue` +* of that option type (or `null`). +* +* Calls writeToArrayBufferCallback(arrayBuffer, offset, jsValue) for non-null jsValues. +* +* This array will have size/align elements for the actual T, then one element +* for the is_ok bool. +*/ +export function optionToBufferForCalling(wasm, jsValue, size, align, allocator, writeToArrayBufferCallback) { + let buf = DiplomatBuf.struct(wasm, size + align, align); + + let buffer; + // Add 1 to the size since we're also accounting for the 0 or 1 is_ok field: + if (align == 8) { + buffer = new BigUint64Array(wasm.memory.buffer, buf.ptr, size / align + 1); + } else if (align == 4) { + buffer = new Uint32Array(wasm.memory.buffer, buf.ptr, size / align + 1); + } else if (align == 2) { + buffer = new Uint16Array(wasm.memory.buffer, buf.ptr, size / align + 1); + } else { + buffer = new Uint8Array(wasm.memory.buffer, buf.ptr, size / align + 1); + } + + buffer.fill(0); + + if (jsValue != null) { + // Note that `buffer.buffer` is the underlying ArrayBuffer (`buffer` is just a view), + // so we must provide the offset pointer (buf.ptr) + writeToArrayBufferCallback(buffer.buffer, buf.ptr, jsValue); + buffer[buffer.length - 1] = 1; + } + + return allocator.alloc(buf).ptr; +} + + +/** +* Given `ptr` in Wasm memory, treat it as an Option with size for type T, +* and return the converted T (converted using `readCallback(wasm, ptr)`) if the Option is Some +* else None. +*/ +export function readOption(wasm, ptr, size, readCallback) { + // Don't need the alignment: diplomat types don't have overridden alignment, + // so the flag will immediately be after the inner struct. + let flag = resultFlag(wasm, ptr, size); + if (flag) { + return readCallback(wasm, ptr); + } else { + return null; + } +} + +/** + * A wrapper around a slice of WASM memory that can be freed manually or + * automatically by the garbage collector. + * + * This type is necessary for Rust functions that take a `&str` or `&[T]`, since + * they can create an edge to this object if they borrow from the str/slice, + * or we can manually free the WASM memory if they don't. + */ +export class DiplomatBuf { + static str8 = (wasm, string) => { + var utf8Length = 0; + for (const codepointString of string) { + let codepoint = codepointString.codePointAt(0); + if (codepoint < 0x80) { + utf8Length += 1 + } else if (codepoint < 0x800) { + utf8Length += 2 + } else if (codepoint < 0x10000) { + utf8Length += 3 + } else { + utf8Length += 4 + } + } + + const ptr = wasm.diplomat_alloc(utf8Length, 1); + + const result = (new TextEncoder()).encodeInto(string, new Uint8Array(wasm.memory.buffer, ptr, utf8Length)); + console.assert(string.length === result.read && utf8Length === result.written, "UTF-8 write error"); + + return new DiplomatBuf(ptr, utf8Length, () => wasm.diplomat_free(ptr, utf8Length, 1)); + } + + static str16 = (wasm, string) => { + const byteLength = string.length * 2; + const ptr = wasm.diplomat_alloc(byteLength, 2); + + const destination = new Uint16Array(wasm.memory.buffer, ptr, string.length); + for (let i = 0; i < string.length; i++) { + destination[i] = string.charCodeAt(i); + } + + return new DiplomatBuf(ptr, string.length, () => wasm.diplomat_free(ptr, byteLength, 2)); + } + + static sliceWrapper = (wasm, buf) => { + const ptr = wasm.diplomat_alloc(8, 4); + let dst = new Uint32Array(wasm.memory.buffer, ptr, 2); + + dst[0] = buf.ptr; + dst[1] = buf.size; + return new DiplomatBuf(ptr, 8, () => { + wasm.diplomat_free(ptr, 8, 4); + buf.free(); + }); + } + + static slice = (wasm, list, rustType) => { + const elementSize = rustType === "u8" || rustType === "i8" || rustType === "boolean" ? 1 : + rustType === "u16" || rustType === "i16" ? 2 : + rustType === "u64" || rustType === "i64" || rustType === "f64" ? 8 : + 4; + + const byteLength = list.length * elementSize; + const ptr = wasm.diplomat_alloc(byteLength, elementSize); + + /** + * Create an array view of the buffer. This gives us the `set` method which correctly handles untyped values + */ + const destination = + rustType === "u8" || rustType === "boolean" ? new Uint8Array(wasm.memory.buffer, ptr, list.length) : + rustType === "i8" ? new Int8Array(wasm.memory.buffer, ptr, list.length) : + rustType === "u16" ? new Uint16Array(wasm.memory.buffer, ptr, list.length) : + rustType === "i16" ? new Int16Array(wasm.memory.buffer, ptr, list.length) : + rustType === "i32" ? new Int32Array(wasm.memory.buffer, ptr, list.length) : + rustType === "u64" ? new BigUint64Array(wasm.memory.buffer, ptr, list.length) : + rustType === "i64" ? new BigInt64Array(wasm.memory.buffer, ptr, list.length) : + rustType === "f32" ? new Float32Array(wasm.memory.buffer, ptr, list.length) : + rustType === "f64" ? new Float64Array(wasm.memory.buffer, ptr, list.length) : + new Uint32Array(wasm.memory.buffer, ptr, list.length); + destination.set(list); + + return new DiplomatBuf(ptr, list.length, () => wasm.diplomat_free(ptr, byteLength, elementSize)); + } + + static strs = (wasm, strings, encoding) => { + let encodeStr = (encoding === "string16") ? DiplomatBuf.str16 : DiplomatBuf.str8; + + const byteLength = strings.length * 4 * 2; + + const ptr = wasm.diplomat_alloc(byteLength, 4); + + const destination = new Uint32Array(wasm.memory.buffer, ptr, byteLength); + + const stringsAlloc = []; + + for (let i = 0; i < strings.length; i++) { + stringsAlloc.push(encodeStr(wasm, strings[i])); + + destination[2 * i] = stringsAlloc[i].ptr; + destination[(2 * i) + 1] = stringsAlloc[i].size; + } + + return new DiplomatBuf(ptr, strings.length, () => { + wasm.diplomat_free(ptr, byteLength, 4); + for (let i = 0; i < stringsAlloc.length; i++) { + stringsAlloc[i].free(); + } + }); + } + + static struct = (wasm, size, align) => { + const ptr = wasm.diplomat_alloc(size, align); + + return new DiplomatBuf(ptr, size, () => { + wasm.diplomat_free(ptr, size, align); + }); + } + + /** + * Generated code calls one of methods these for each allocation, to either + * free directly after the FFI call, to leak (to create a &'static), or to + * register the buffer with the garbage collector (to create a &'a). + */ + free; + + constructor(ptr, size, free) { + this.ptr = ptr; + this.size = size; + this.free = free; + this.leak = () => { }; + this.releaseToGarbageCollector = () => DiplomatBufferFinalizer.register(this, () => this.free()); + } + + splat() { + return [this.ptr, this.size]; + } + + /** + * Write the (ptr, len) pair to an array buffer at byte offset `offset` + */ + writePtrLenToArrayBuffer(arrayBuffer, offset) { + writeToArrayBuffer(arrayBuffer, offset, this.ptr, Uint32Array); + writeToArrayBuffer(arrayBuffer, offset + 4, this.size, Uint32Array); + } +} + +/** + * Helper class for creating and managing `diplomat_buffer_write`. + * Meant to minimize direct calls to `wasm`. + */ +export class DiplomatWriteBuf { + leak; + + #wasm; + #buffer; + + constructor(wasm) { + this.#wasm = wasm; + this.#buffer = this.#wasm.diplomat_buffer_write_create(0); + + this.leak = () => { }; + } + + free() { + this.#wasm.diplomat_buffer_write_destroy(this.#buffer); + } + + releaseToGarbageCollector() { + DiplomatBufferFinalizer.register(this, () => this.free()); + } + + readString8() { + return readString8(this.#wasm, this.ptr, this.size); + } + + get buffer() { + return this.#buffer; + } + + get ptr() { + return this.#wasm.diplomat_buffer_write_get_bytes(this.#buffer); + } + + get size() { + return this.#wasm.diplomat_buffer_write_len(this.#buffer); + } +} + +/** + * Represents an underlying slice that we've grabbed from WebAssembly. + * You can treat this in JS as a regular slice of primitives, but it handles additional data for you behind the scenes. + */ +export class DiplomatSlice { + #wasm; + + #bufferType; + get bufferType() { + return this.#bufferType; + } + + #buffer; + get buffer() { + return this.#buffer; + } + + #lifetimeEdges; + + constructor(wasm, buffer, bufferType, lifetimeEdges) { + this.#wasm = wasm; + + const [ptr, size] = new Uint32Array(this.#wasm.memory.buffer, buffer, 2); + + this.#buffer = new bufferType(this.#wasm.memory.buffer, ptr, size); + this.#bufferType = bufferType; + + this.#lifetimeEdges = lifetimeEdges; + } + + getValue() { + return this.#buffer; + } + + [Symbol.toPrimitive]() { + return this.getValue(); + } + + valueOf() { + return this.getValue(); + } +} + +export class DiplomatSlicePrimitive extends DiplomatSlice { + constructor(wasm, buffer, sliceType, lifetimeEdges) { + const [ptr, size] = new Uint32Array(wasm.memory.buffer, buffer, 2); + + let arrayType; + switch (sliceType) { + case "u8": + case "boolean": + arrayType = Uint8Array; + break; + case "i8": + arrayType = Int8Array; + break; + case "u16": + arrayType = Uint16Array; + break; + case "i16": + arrayType = Int16Array; + break; + case "i32": + arrayType = Int32Array; + break; + case "u32": + arrayType = Uint32Array; + break; + case "i64": + arrayType = BigInt64Array; + break; + case "u64": + arrayType = BigUint64Array; + break; + case "f32": + arrayType = Float32Array; + break; + case "f64": + arrayType = Float64Array; + break; + default: + console.error("Unrecognized bufferType ", bufferType); + } + + super(wasm, buffer, arrayType, lifetimeEdges); + } +} + +export class DiplomatSliceStr extends DiplomatSlice { + #decoder; + + constructor(wasm, buffer, stringEncoding, lifetimeEdges) { + let encoding; + switch (stringEncoding) { + case "string8": + encoding = Uint8Array; + break; + case "string16": + encoding = Uint16Array; + break; + default: + console.error("Unrecognized stringEncoding ", stringEncoding); + break; + } + super(wasm, buffer, encoding, lifetimeEdges); + + if (stringEncoding === "string8") { + this.#decoder = new TextDecoder('utf-8'); + } + } + + getValue() { + switch (this.bufferType) { + case Uint8Array: + return this.#decoder.decode(super.getValue()); + case Uint16Array: + return String.fromCharCode.apply(null, super.getValue()); + default: + return null; + } + } + + toString() { + return this.getValue(); + } +} + +export class DiplomatSliceStrings extends DiplomatSlice { + #strings = []; + constructor(wasm, buffer, stringEncoding, lifetimeEdges) { + super(wasm, buffer, Uint32Array, lifetimeEdges); + + for (let i = this.buffer.byteOffset; i < this.buffer.byteLength; i += this.buffer.BYTES_PER_ELEMENT * 2) { + this.#strings.push(new DiplomatSliceStr(wasm, i, stringEncoding, lifetimeEdges)); + } + } + + getValue() { + return this.#strings; + } +} + +/** + * A number of Rust functions in WebAssembly require a buffer to populate struct, slice, Option<> or Result<> types with information. + * {@link DiplomatReceiveBuf} allocates a buffer in WebAssembly, which can then be passed into functions with the {@link DiplomatReceiveBuf.buffer} + * property. + */ +export class DiplomatReceiveBuf { + #wasm; + + #size; + #align; + + #hasResult; + + #buffer; + + constructor(wasm, size, align, hasResult) { + this.#wasm = wasm; + + this.#size = size; + this.#align = align; + + this.#hasResult = hasResult; + + this.#buffer = this.#wasm.diplomat_alloc(this.#size, this.#align); + + this.leak = () => { }; + } + + free() { + this.#wasm.diplomat_free(this.#buffer, this.#size, this.#align); + } + + get buffer() { + return this.#buffer; + } + + /** + * Only for when a DiplomatReceiveBuf is allocating a buffer for an `Option<>` or a `Result<>` type. + * + * This just checks the last byte for a successful result (assuming that Rust's compiler does not change). + */ + get resultFlag() { + if (this.#hasResult) { + return resultFlag(this.#wasm, this.#buffer, this.#size - 1); + } else { + return true; + } + } +} + +/** + * For preallocating owned slices + * + * Doesn't actually do anything, but helps code readability of generated code + */ +export class OwnedSliceLeaker { + constructor() { + } + + /** + * Leak an item + * @param {DiplomatBuf} item + * @returns {DiplomatBuf} + */ + static alloc(item) { + item.leak(); + return item; + } +} + +/** + * For cleaning up slices inside struct _intoFFI functions. + * Based somewhat on how the Dart backend handles slice cleanup. + * + * We want to ensure a slice only lasts as long as its struct, so we have a `functionCleanupArena` CleanupArena that we use in each method for any slice that needs to be cleaned up. It lasts only as long as the function is called for. + * + * Then we have `createWith`, which is meant for longer lasting slices. It takes an array of edges and will last as long as those edges do. Cleanup is only called later. + */ +export class CleanupArena { + #items = []; + + constructor() { + } + + /** + * When this arena is freed, call .free() on the given item. + * @param {DiplomatBuf} item + * @returns {DiplomatBuf} + */ + alloc(item) { + this.#items.push(item); + return item; + } + /** + * Create a new CleanupArena, append it to any edge arrays passed down, and return it. + * @param {Array} edgeArrays + * @returns {CleanupArena} + */ + static createWith(...edgeArrays) { + let self = new CleanupArena(); + for (let edgeArray of edgeArrays) { + if (edgeArray != null) { + edgeArray.push(self); + } + } + DiplomatBufferFinalizer.register(self, () => self.free()); + return self; + } + + /** + * If given edge arrays, create a new CleanupArena, append it to any edge arrays passed down, and return it. + * Else return the function-local cleanup arena + * @param {CleanupArena} functionCleanupArena + * @param {Array} edgeArrays + * @returns {DiplomatBuf} + */ + static maybeCreateWith(functionCleanupArena, ...edgeArrays) { + if (edgeArrays.length > 0) { + return CleanupArena.createWith(...edgeArrays); + } else { + return functionCleanupArena + } + } + + free() { + this.#items.forEach((i) => { + i.free(); + }); + + this.#items.length = 0; + } +} + +/** + * Similar to {@link CleanupArena}, but for holding on to slices until a method is called, + * after which we rely on the GC to free them. + * + * This is when you may want to use a slice longer than the body of the method. + * + * At first glance this seems unnecessary, since we will be holding these slices in edge arrays anyway, + * however, if an edge array ends up unused, then we do actually need something to hold it for the duration + * of the method call. + */ +export class GarbageCollectorGrip { + #items = []; + + alloc(item) { + this.#items.push(item); + return item; + } + + releaseToGarbageCollector() { + this.#items.forEach((i) => { + i.releaseToGarbageCollector(); + }); + + this.#items.length = 0; + } +} + +const DiplomatBufferFinalizer = new FinalizationRegistry(free => free()); + +/** + * For allocating and cleaning up structs to be passed into the C Spec WASM ABI. + * This is primarily intended for storing structures being passed from Javascript to Rust. + * The maximal size any parameters we could ever need to store can be calculated by Diplomat, so we can pre-allocate a buffer + * and allocate structs there. + * + * Created/reserved when we load in the WebAssembly. + */ +export class FunctionParamAllocator { + #ptr = 0; + #capacity = 0; + + /** + * A stack of pointers to Rust types allocated with {@link alloc}. + * The stack is popped with {@link get}, returning the most recently allocated pointer. + * Note that this does NOT clear allocated memory, this must be done with {@link clean}. + * Each pointer is guaranteed to be within the bounds of #ptr. + * + */ + #allocated = []; + /** + * The size of everything currently allocated. + * The size is only reset with {@link clean}. + */ + #currentPtr = 0; + + /** + * Reserve {@link #ptr} with a specific capacity. + * @param {WebAssembly.Module} wasm Web assembly module to allocate into. + * @param {number} capacity How large, in bytes, the buffer should be. + */ + reserve(symbol, wasm, capacity) { + if (symbol !== internalConstructor) { + throw new Error(".reserve should only be called internally."); + } + if (this.#ptr !== 0) { + if (this.#currentPtr > 0) { + throw new Error("Cannot reserve additional space if memory has already been allocated! .clear() must be called."); + } else { + wasm.diplomat_free(this.#ptr, this.#capacity, 1); + } + } + + this.#capacity = capacity; + // FunctionParamAllocator is global, so this will be freed when the webpage closes: + this.#ptr = wasm.diplomat_alloc(this.#capacity, 1); + } + + /** + * Reserves part of {@link #ptr} to be used for allocating function parameters on the stack to Rust memory. + * @param {number} size The size of the buffer to reserve + * @returns A pointer to what was just reserved. + */ + alloc(size) { + if (this.#currentPtr + size > this.#capacity) { + throw new Error(`Could not allocate size ${this.#currentPtr} + ${size} > ${this.#capacity}. Please consider adjusting reserve()`); + } + this.#allocated.push(this.#ptr + this.#currentPtr); + this.#currentPtr += size; + return this.#ptr + (this.#currentPtr - size); + } + + /** + * Pops the most recently allocated pointer on the stack. + * @returns The most recently allocated pointer on the stack. + */ + pop() { + return this.#allocated.pop(); + } + + /** + * Free up memory on the buffer. + */ + clean() { + this.#currentPtr = 0; + + this.#allocated = []; + } +} + +export const FUNCTION_PARAM_ALLOC = new FunctionParamAllocator(); \ No newline at end of file diff --git a/interop/packages/typescript/lib/diplomat-wasm.mjs b/interop/packages/typescript/lib/diplomat-wasm.mjs new file mode 100644 index 0000000..010ab35 --- /dev/null +++ b/interop/packages/typescript/lib/diplomat-wasm.mjs @@ -0,0 +1,52 @@ +import cfg from '../diplomat.config.mjs'; +import {readString8} from './diplomat-runtime.mjs' + +let wasm; + +const imports = { +env: { + diplomat_console_debug_js(ptr, len) { + console.debug(readString8(wasm, ptr, len)); + }, + diplomat_console_error_js(ptr, len) { + console.error(readString8(wasm, ptr, len)); + }, + diplomat_console_info_js(ptr, len) { + console.info(readString8(wasm, ptr, len)); + }, + diplomat_console_log_js(ptr, len) { + console.log(readString8(wasm, ptr, len)); + }, + diplomat_console_warn_js(ptr, len) { + console.warn(readString8(wasm, ptr, len)); + }, + diplomat_throw_error_js(ptr, len) { + throw new Error(readString8(wasm, ptr, len)); + } +} +} + +if (globalThis.process?.getBuiltinModule) { + // Node (>=22) + const fs = globalThis.process.getBuiltinModule('fs'); + const wasmFile = new Uint8Array(fs.readFileSync(cfg['wasm_path'])); + const loadedWasm = await WebAssembly.instantiate(wasmFile, imports); + wasm = loadedWasm.instance.exports; +} else if (globalThis.process) { + // Node (<22) + const fs = await import('fs'); + const wasmFile = new Uint8Array(fs.readFileSync(cfg['wasm_path'])); + const loadedWasm = await WebAssembly.instantiate(wasmFile, imports); + wasm = loadedWasm.instance.exports; +} else { + // Browser + const loadedWasm = await WebAssembly.instantiateStreaming(fetch(cfg['wasm_path']), imports); + wasm = loadedWasm.instance.exports; +} + +wasm.diplomat_init(); +if (cfg['init'] !== undefined) { + cfg['init'](wasm); +} + +export default wasm; diff --git a/interop/packages/typescript/lib/index.d.ts b/interop/packages/typescript/lib/index.d.ts new file mode 100644 index 0000000..7ca6020 --- /dev/null +++ b/interop/packages/typescript/lib/index.d.ts @@ -0,0 +1,49 @@ + +export { codepoint } from './diplomat-runtime'; + + +export { CivilDate, CivilDate_obj } from "./CivilDate" + +export { HebrewDate, HebrewDate_obj } from "./HebrewDate" + +export { HolidayEntry, HolidayEntry_obj } from "./HolidayEntry" + +export { AmudResult, AmudResult_obj } from "./AmudResult" + +export { DafResult, DafResult_obj } from "./DafResult" + +export { MishnaResult, MishnaResult_obj } from "./MishnaResult" + +export { MishnasResult, MishnasResult_obj } from "./MishnasResult" + +export { PirkeiAvosResult, PirkeiAvosResult_obj } from "./PirkeiAvosResult" + +export { TehillimResult, TehillimResult_obj } from "./TehillimResult" + +export { CalculatorConfig, CalculatorConfig_obj } from "./CalculatorConfig" + +export { Calendar } from "./Calendar" + +export { HolidayList } from "./HolidayList" + +export { Limudim } from "./Limudim" + +export { ZmanPresets } from "./ZmanPresets" + +export { FfiLocation } from "./FfiLocation" + +export { FfiZmanimCalculator } from "./FfiZmanimCalculator" + +export { HolidayCode } from "./HolidayCode" + +export { ParshaCode } from "./ParshaCode" + +export { YearLengthTypeCode } from "./YearLengthTypeCode" + +export { SideCode } from "./SideCode" + +export { TractateCode } from "./TractateCode" + +export { ZmanPresetId } from "./ZmanPresetId" + +export { ZmanimErrorCode } from "./ZmanimErrorCode" diff --git a/interop/packages/typescript/lib/index.mjs b/interop/packages/typescript/lib/index.mjs new file mode 100644 index 0000000..b0c493a --- /dev/null +++ b/interop/packages/typescript/lib/index.mjs @@ -0,0 +1,52 @@ + + +export { CivilDate } from "./CivilDate.mjs" + +export { HebrewDate } from "./HebrewDate.mjs" + +export { HolidayEntry } from "./HolidayEntry.mjs" + +export { AmudResult } from "./AmudResult.mjs" + +export { DafResult } from "./DafResult.mjs" + +export { MishnaResult } from "./MishnaResult.mjs" + +export { MishnasResult } from "./MishnasResult.mjs" + +export { PirkeiAvosResult } from "./PirkeiAvosResult.mjs" + +export { TehillimResult } from "./TehillimResult.mjs" + +export { CalculatorConfig } from "./CalculatorConfig.mjs" + +export { Calendar } from "./Calendar.mjs" + +export { HolidayList } from "./HolidayList.mjs" + +export { Limudim } from "./Limudim.mjs" + +export { ZmanPresets } from "./ZmanPresets.mjs" + +export { FfiLocation } from "./FfiLocation.mjs" + +export { FfiZmanimCalculator } from "./FfiZmanimCalculator.mjs" + +export { HolidayCode } from "./HolidayCode.mjs" + +export { ParshaCode } from "./ParshaCode.mjs" + +export { YearLengthTypeCode } from "./YearLengthTypeCode.mjs" + +export { SideCode } from "./SideCode.mjs" + +export { TractateCode } from "./TractateCode.mjs" + +export { ZmanPresetId } from "./ZmanPresetId.mjs" + +export { ZmanimErrorCode } from "./ZmanimErrorCode.mjs" + +import wasm from "./diplomat-wasm.mjs"; +import {FUNCTION_PARAM_ALLOC, internalConstructor} from "./diplomat-runtime.mjs"; + +FUNCTION_PARAM_ALLOC.reserve(internalConstructor, wasm, 32); diff --git a/interop/packages/typescript/package-lock.json b/interop/packages/typescript/package-lock.json new file mode 100644 index 0000000..0177bc2 --- /dev/null +++ b/interop/packages/typescript/package-lock.json @@ -0,0 +1,33 @@ +{ + "name": "kosher-rust-for-typescript", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "kosher-rust-for-typescript", + "version": "1.0.0", + "license": "MIT", + "devDependencies": { + "typescript": "^5.8.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + } + } +} diff --git a/interop/packages/typescript/package.json b/interop/packages/typescript/package.json new file mode 100644 index 0000000..9576e40 --- /dev/null +++ b/interop/packages/typescript/package.json @@ -0,0 +1,29 @@ +{ + "name": "kosher-rust-for-typescript", + "description": "Kosher Rust for TypeScript and JavaScript (Diplomat WASM bindings)", + "version": "1.0.0", + "type": "module", + "license": "MIT", + "exports": { + ".": { + "types": "./lib/index.d.ts", + "default": "./lib/index.mjs" + } + }, + "files": [ + "diplomat.config.mjs", + "lib" + ], + "scripts": { + "build:wasm": "node scripts/build-wasm.mjs", + "generate": "node scripts/generate.mjs", + "test": "npm run build:wasm && node --test test/*.test.mjs", + "typecheck": "tsc --noEmit" + }, + "engines": { + "node": ">=18" + }, + "devDependencies": { + "typescript": "^5.8.3" + } +} diff --git a/interop/packages/typescript/scripts/build-wasm.mjs b/interop/packages/typescript/scripts/build-wasm.mjs new file mode 100644 index 0000000..c81b1cd --- /dev/null +++ b/interop/packages/typescript/scripts/build-wasm.mjs @@ -0,0 +1,22 @@ +import { spawnSync } from "node:child_process"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const workspaceRoot = path.resolve( + path.dirname(fileURLToPath(import.meta.url)), + "../../..", +); +const profile = process.env.CARGO_PROFILE ?? "debug"; + +const args = ["build", "-p", "interop", "--target", "wasm32-unknown-unknown"]; +if (profile === "release") { + args.push("--release"); +} + +const result = spawnSync("cargo", args, { + cwd: workspaceRoot, + stdio: "inherit", + shell: true, +}); + +process.exit(result.status ?? 1); diff --git a/interop/packages/typescript/scripts/generate.mjs b/interop/packages/typescript/scripts/generate.mjs new file mode 100644 index 0000000..437a305 --- /dev/null +++ b/interop/packages/typescript/scripts/generate.mjs @@ -0,0 +1,22 @@ +import { spawnSync } from "node:child_process"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const packageRoot = path.resolve( + path.dirname(fileURLToPath(import.meta.url)), + "..", +); +const interopDir = path.join(packageRoot, "../.."); +const libDir = path.join(packageRoot, "lib"); + +const result = spawnSync( + "diplomat-tool", + ["js", libDir, "--entry", "src/lib.rs"], + { + cwd: interopDir, + stdio: "inherit", + shell: true, + }, +); + +process.exit(result.status ?? 1); diff --git a/interop/packages/typescript/test/smoke.test.mjs b/interop/packages/typescript/test/smoke.test.mjs new file mode 100644 index 0000000..da6abff --- /dev/null +++ b/interop/packages/typescript/test/smoke.test.mjs @@ -0,0 +1,41 @@ +import assert from "node:assert/strict"; +import test from "node:test"; + +import { + Calendar, + CivilDate, + Limudim, + TractateCode, + ZmanPresets, +} from "../lib/index.mjs"; + +test("gregorian/hebrew round trip via Calendar", () => { + const calendar = new Calendar(); + const civil = new CivilDate({ year: 2024, month: 1, day: 20 }); + + const hebrew = calendar.gregorianToHebrew(civil); + assert.ok(hebrew); + assert.equal(hebrew.year, 5784); + assert.equal(hebrew.month, 5); + assert.equal(hebrew.day, 10); + + const back = calendar.hebrewToGregorian(hebrew); + assert.ok(back); + assert.equal(back.year, civil.year); + assert.equal(back.month, civil.month); + assert.equal(back.day, civil.day); +}); + +test("daf yomi bavli via Limudim", () => { + const limudim = new Limudim(); + const daf = limudim.dafYomiBavli(2017, 12, 28); + + assert.ok(daf); + assert.equal(daf.tractate, TractateCode.Shevuos); + assert.equal(daf.page, 30); +}); + +test("preset count via ZmanPresets", () => { + const presets = new ZmanPresets(); + assert.equal(presets.presetCount(), 167); +}); diff --git a/interop/packages/typescript/tsconfig.json b/interop/packages/typescript/tsconfig.json new file mode 100644 index 0000000..c8b6ab0 --- /dev/null +++ b/interop/packages/typescript/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "strict": true, + "noEmit": true, + "skipLibCheck": true + }, + "include": ["lib/**/*.d.ts"] +} diff --git a/interop/rust-toolchain.toml b/interop/rust-toolchain.toml new file mode 100644 index 0000000..18d200f --- /dev/null +++ b/interop/rust-toolchain.toml @@ -0,0 +1,26 @@ +[toolchain] +channel = "1.93.0" +components = ["rustfmt", "clippy"] +targets = [ + # Android + "armv7-linux-androideabi", + "aarch64-linux-android", + "x86_64-linux-android", + + # iOS (device + simulator) + "aarch64-apple-ios", + "aarch64-apple-ios-sim", + "x86_64-apple-ios", + + # Windows + "aarch64-pc-windows-msvc", + "x86_64-pc-windows-msvc", + + # Linux + "aarch64-unknown-linux-gnu", + "x86_64-unknown-linux-gnu", + + # macOS + "aarch64-apple-darwin", + "x86_64-apple-darwin", +] diff --git a/interop/src/calendar.rs b/interop/src/calendar.rs new file mode 100644 index 0000000..5d90146 --- /dev/null +++ b/interop/src/calendar.rs @@ -0,0 +1,524 @@ +//! Calendar FFI bridge. + +#[diplomat::bridge] +mod ffi { + use icu_calendar::cal::Hebrew; + use kosher_rust::calendar::{HebrewCalendar, HebrewHolidayCalendar}; + + use crate::common::{ + civil_date_to_jiff, decode_hebrew_month, gregorian_to_hebrew as common_gregorian_to_hebrew, + hebrew_to_gregorian as common_hebrew_to_gregorian, holiday_to_codes, + }; + + /// Gregorian civil date (year, month, day). + #[derive(Copy, Clone)] + pub struct CivilDate { + pub year: i32, + pub month: u8, + pub day: u8, + } + + /// Hebrew calendar date (year, month code, day). + #[derive(Copy, Clone)] + pub struct HebrewDate { + pub year: i32, + pub month: u8, + pub day: u8, + } + + /// A holiday occurring on a date, with an optional sub-day (Chanukah, Omer). + #[derive(Copy, Clone)] + pub struct HolidayEntry { + pub code: HolidayCode, + /// Day within Chanukah (1–8) or Omer (1–49); zero otherwise. + pub sub_day: u8, + } + + pub enum HolidayCode { + ErevPesach, + Pesach, + CholHamoedPesach, + PesachSheni, + ErevShavuos, + Shavuos, + SeventeenthOfTammuz, + TishahBav, + TuBav, + ErevRoshHashana, + RoshHashana, + FastOfGedalyah, + ErevYomKippur, + YomKippur, + ErevSuccos, + Succos, + CholHamoedSuccos, + HoshanaRabbah, + SheminiAtzeres, + SimchasTorah, + Chanukah, + TenthOfTeves, + TuBshvat, + FastOfEsther, + Purim, + ShushanPurim, + PurimKatan, + RoshChodesh, + YomHaShoah, + YomHazikaron, + YomHaatzmaut, + YomYerushalayim, + LagBomer, + ShushanPurimKatan, + IsruChag, + YomKippurKatan, + Behab, + FastOfTheFirstborn, + CountOfTheOmer, + BirchasHachamah, + MacharHachodesh, + ShabbosMevarchim, + } + + pub enum ParshaCode { + Bereshis, + Noach, + LechLecha, + Vayera, + ChayeiSara, + Toldos, + Vayetzei, + Vayishlach, + Vayeshev, + Miketz, + Vayigash, + Vayechi, + Shemos, + Vaera, + Bo, + Beshalach, + Yisro, + Mishpatim, + Terumah, + Tetzaveh, + KiSisa, + Vayakhel, + Pekudei, + Vayikra, + Tzav, + Shmini, + Tazria, + Metzora, + AchreiMos, + Kedoshim, + Emor, + Behar, + Bechukosai, + Bamidbar, + Nasso, + Behaaloscha, + Shlach, + Korach, + Chukas, + Balak, + Pinchas, + Matos, + Masei, + Devarim, + Vaeschanan, + Eikev, + Reeh, + Shoftim, + KiSeitzei, + KiSavo, + Nitzavim, + Vayeilech, + HaAzinu, + VezosHabracha, + VayakhelPekudei, + TazriaMetzora, + AchreiMosKedoshim, + BeharBechukosai, + ChukasBalak, + MatosMasei, + NitzavimVayeilech, + Shekalim, + Zachor, + Parah, + Hachodesh, + Shuva, + Shira, + Hagadol, + Chazon, + Nachamu, + } + + pub enum YearLengthTypeCode { + Chaserim, + Kesidran, + Shelaimim, + } + + #[diplomat::opaque] + pub struct HolidayList(Vec); + + impl HolidayList { + pub fn len(&self) -> u32 { + u32::try_from(self.0.len()).unwrap_or(u32::MAX) + } + + pub fn get(&self, index: u32) -> Option { + self.0.get(index as usize).copied() + } + } + + fn to_internal(date: CivilDate) -> crate::common::CivilDate { + crate::common::CivilDate { + year: date.year, + month: date.month, + day: date.day, + } + } + + fn to_internal_hebrew(date: HebrewDate) -> crate::common::HebrewDate { + crate::common::HebrewDate { + year: date.year, + month: date.month, + day: date.day, + } + } + + fn to_ffi_hebrew(date: crate::common::HebrewDate) -> HebrewDate { + HebrewDate { + year: date.year, + month: date.month, + day: date.day, + } + } + + fn to_ffi_holiday_code(code: crate::common::HolidayCode) -> HolidayCode { + use crate::common::HolidayCode as C; + match code { + C::ErevPesach => HolidayCode::ErevPesach, + C::Pesach => HolidayCode::Pesach, + C::CholHamoedPesach => HolidayCode::CholHamoedPesach, + C::PesachSheni => HolidayCode::PesachSheni, + C::ErevShavuos => HolidayCode::ErevShavuos, + C::Shavuos => HolidayCode::Shavuos, + C::SeventeenthOfTammuz => HolidayCode::SeventeenthOfTammuz, + C::TishahBav => HolidayCode::TishahBav, + C::TuBav => HolidayCode::TuBav, + C::ErevRoshHashana => HolidayCode::ErevRoshHashana, + C::RoshHashana => HolidayCode::RoshHashana, + C::FastOfGedalyah => HolidayCode::FastOfGedalyah, + C::ErevYomKippur => HolidayCode::ErevYomKippur, + C::YomKippur => HolidayCode::YomKippur, + C::ErevSuccos => HolidayCode::ErevSuccos, + C::Succos => HolidayCode::Succos, + C::CholHamoedSuccos => HolidayCode::CholHamoedSuccos, + C::HoshanaRabbah => HolidayCode::HoshanaRabbah, + C::SheminiAtzeres => HolidayCode::SheminiAtzeres, + C::SimchasTorah => HolidayCode::SimchasTorah, + C::Chanukah => HolidayCode::Chanukah, + C::TenthOfTeves => HolidayCode::TenthOfTeves, + C::TuBshvat => HolidayCode::TuBshvat, + C::FastOfEsther => HolidayCode::FastOfEsther, + C::Purim => HolidayCode::Purim, + C::ShushanPurim => HolidayCode::ShushanPurim, + C::PurimKatan => HolidayCode::PurimKatan, + C::RoshChodesh => HolidayCode::RoshChodesh, + C::YomHaShoah => HolidayCode::YomHaShoah, + C::YomHazikaron => HolidayCode::YomHazikaron, + C::YomHaatzmaut => HolidayCode::YomHaatzmaut, + C::YomYerushalayim => HolidayCode::YomYerushalayim, + C::LagBomer => HolidayCode::LagBomer, + C::ShushanPurimKatan => HolidayCode::ShushanPurimKatan, + C::IsruChag => HolidayCode::IsruChag, + C::YomKippurKatan => HolidayCode::YomKippurKatan, + C::Behab => HolidayCode::Behab, + C::FastOfTheFirstborn => HolidayCode::FastOfTheFirstborn, + C::CountOfTheOmer => HolidayCode::CountOfTheOmer, + C::BirchasHachamah => HolidayCode::BirchasHachamah, + C::MacharHachodesh => HolidayCode::MacharHachodesh, + C::ShabbosMevarchim => HolidayCode::ShabbosMevarchim, + } + } + + fn to_ffi_parsha(code: crate::common::ParshaCode) -> ParshaCode { + use crate::common::ParshaCode as C; + match code { + C::Bereshis => ParshaCode::Bereshis, + C::Noach => ParshaCode::Noach, + C::LechLecha => ParshaCode::LechLecha, + C::Vayera => ParshaCode::Vayera, + C::ChayeiSara => ParshaCode::ChayeiSara, + C::Toldos => ParshaCode::Toldos, + C::Vayetzei => ParshaCode::Vayetzei, + C::Vayishlach => ParshaCode::Vayishlach, + C::Vayeshev => ParshaCode::Vayeshev, + C::Miketz => ParshaCode::Miketz, + C::Vayigash => ParshaCode::Vayigash, + C::Vayechi => ParshaCode::Vayechi, + C::Shemos => ParshaCode::Shemos, + C::Vaera => ParshaCode::Vaera, + C::Bo => ParshaCode::Bo, + C::Beshalach => ParshaCode::Beshalach, + C::Yisro => ParshaCode::Yisro, + C::Mishpatim => ParshaCode::Mishpatim, + C::Terumah => ParshaCode::Terumah, + C::Tetzaveh => ParshaCode::Tetzaveh, + C::KiSisa => ParshaCode::KiSisa, + C::Vayakhel => ParshaCode::Vayakhel, + C::Pekudei => ParshaCode::Pekudei, + C::Vayikra => ParshaCode::Vayikra, + C::Tzav => ParshaCode::Tzav, + C::Shmini => ParshaCode::Shmini, + C::Tazria => ParshaCode::Tazria, + C::Metzora => ParshaCode::Metzora, + C::AchreiMos => ParshaCode::AchreiMos, + C::Kedoshim => ParshaCode::Kedoshim, + C::Emor => ParshaCode::Emor, + C::Behar => ParshaCode::Behar, + C::Bechukosai => ParshaCode::Bechukosai, + C::Bamidbar => ParshaCode::Bamidbar, + C::Nasso => ParshaCode::Nasso, + C::Behaaloscha => ParshaCode::Behaaloscha, + C::Shlach => ParshaCode::Shlach, + C::Korach => ParshaCode::Korach, + C::Chukas => ParshaCode::Chukas, + C::Balak => ParshaCode::Balak, + C::Pinchas => ParshaCode::Pinchas, + C::Matos => ParshaCode::Matos, + C::Masei => ParshaCode::Masei, + C::Devarim => ParshaCode::Devarim, + C::Vaeschanan => ParshaCode::Vaeschanan, + C::Eikev => ParshaCode::Eikev, + C::Reeh => ParshaCode::Reeh, + C::Shoftim => ParshaCode::Shoftim, + C::KiSeitzei => ParshaCode::KiSeitzei, + C::KiSavo => ParshaCode::KiSavo, + C::Nitzavim => ParshaCode::Nitzavim, + C::Vayeilech => ParshaCode::Vayeilech, + C::HaAzinu => ParshaCode::HaAzinu, + C::VezosHabracha => ParshaCode::VezosHabracha, + C::VayakhelPekudei => ParshaCode::VayakhelPekudei, + C::TazriaMetzora => ParshaCode::TazriaMetzora, + C::AchreiMosKedoshim => ParshaCode::AchreiMosKedoshim, + C::BeharBechukosai => ParshaCode::BeharBechukosai, + C::ChukasBalak => ParshaCode::ChukasBalak, + C::MatosMasei => ParshaCode::MatosMasei, + C::NitzavimVayeilech => ParshaCode::NitzavimVayeilech, + C::Shekalim => ParshaCode::Shekalim, + C::Zachor => ParshaCode::Zachor, + C::Parah => ParshaCode::Parah, + C::Hachodesh => ParshaCode::Hachodesh, + C::Shuva => ParshaCode::Shuva, + C::Shira => ParshaCode::Shira, + C::Hagadol => ParshaCode::Hagadol, + C::Chazon => ParshaCode::Chazon, + C::Nachamu => ParshaCode::Nachamu, + } + } + + fn gregorian_to_hebrew_impl(date: CivilDate) -> Option { + common_gregorian_to_hebrew(to_internal(date)).map(to_ffi_hebrew) + } + + fn hebrew_to_gregorian_impl(date: HebrewDate) -> Option { + common_hebrew_to_gregorian(to_internal_hebrew(date)).map(|d| CivilDate { + year: d.year, + month: d.month, + day: d.day, + }) + } + + fn holidays_on_date_impl(date: CivilDate, in_israel: bool, use_modern_holidays: bool) -> Option> { + let jiff = civil_date_to_jiff(to_internal(date))?; + let items = jiff + .holidays(in_israel, use_modern_holidays) + .map(|holiday| { + let (code, sub_day) = holiday_to_codes(holiday); + HolidayEntry { + code: to_ffi_holiday_code(code), + sub_day, + } + }) + .collect(); + Some(Box::new(HolidayList(items))) + } + + fn is_assur_bemelacha_impl(date: CivilDate, in_israel: bool) -> Option { + let jiff = civil_date_to_jiff(to_internal(date))?; + Some(jiff.is_assur_bemelacha(in_israel)) + } + + fn has_candle_lighting_impl(date: CivilDate, in_israel: bool) -> Option { + let jiff = civil_date_to_jiff(to_internal(date))?; + Some(jiff.has_candle_lighting(in_israel)) + } + + fn todays_parsha_impl(date: CivilDate, in_israel: bool) -> Option { + let jiff = civil_date_to_jiff(to_internal(date))?; + jiff.todays_parsha(in_israel) + .map(|p| to_ffi_parsha(crate::common::ParshaCode::from(p))) + } + + fn special_parsha_impl(date: CivilDate, in_israel: bool) -> Option { + let jiff = civil_date_to_jiff(to_internal(date))?; + jiff.special_parsha(in_israel) + .map(|p| to_ffi_parsha(crate::common::ParshaCode::from(p))) + } + + fn upcoming_parsha_impl(date: CivilDate, in_israel: bool) -> Option { + let jiff = civil_date_to_jiff(to_internal(date))?; + jiff.upcoming_parsha(in_israel) + .map(|p| to_ffi_parsha(crate::common::ParshaCode::from(p))) + } + + fn cheshvan_kislev_kviah_impl(year: i32) -> Option { + Hebrew::cheshvan_kislev_kviah(year).map(|value| match crate::common::YearLengthTypeCode::from(value) { + crate::common::YearLengthTypeCode::Chaserim => YearLengthTypeCode::Chaserim, + crate::common::YearLengthTypeCode::Kesidran => YearLengthTypeCode::Kesidran, + crate::common::YearLengthTypeCode::Shelaimim => YearLengthTypeCode::Shelaimim, + }) + } + + /// Converts a Gregorian date to Hebrew. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn gregorian_to_hebrew(date: CivilDate) -> Option { + gregorian_to_hebrew_impl(date) + } + + /// Converts a Hebrew date to Gregorian. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn hebrew_to_gregorian(date: HebrewDate) -> Option { + hebrew_to_gregorian_impl(date) + } + + /// Returns holidays occurring on a Gregorian date. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn holidays_on_date(date: CivilDate, in_israel: bool, use_modern_holidays: bool) -> Option> { + holidays_on_date_impl(date, in_israel, use_modern_holidays) + } + + /// Returns whether work is forbidden on this date. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn is_assur_bemelacha(date: CivilDate, in_israel: bool) -> Option { + is_assur_bemelacha_impl(date, in_israel) + } + + /// Returns whether candle lighting occurs on this date. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn has_candle_lighting(date: CivilDate, in_israel: bool) -> Option { + has_candle_lighting_impl(date, in_israel) + } + + /// Returns the weekly parsha when this date is Shabbat. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn todays_parsha(date: CivilDate, in_israel: bool) -> Option { + todays_parsha_impl(date, in_israel) + } + + /// Returns the special Shabbat designation when applicable. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn special_parsha(date: CivilDate, in_israel: bool) -> Option { + special_parsha_impl(date, in_israel) + } + + /// Returns the parsha for the next Shabbat on or after this date. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn upcoming_parsha(date: CivilDate, in_israel: bool) -> Option { + upcoming_parsha_impl(date, in_israel) + } + + /// Returns the number of days in a Hebrew year. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn days_in_hebrew_year(year: i32) -> Option { + Hebrew::days_in_hebrew_year(year) + } + + /// Returns the number of days in a Hebrew month. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn days_in_hebrew_month(year: i32, month: u8) -> Option { + let month = decode_hebrew_month(month)?; + Hebrew::days_in_hebrew_month(year, month) + } + + /// Returns whether a Hebrew year is a leap year. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn is_hebrew_leap_year(year: i32) -> bool { + Hebrew::is_hebrew_leap_year(year) + } + + /// Returns the Cheshvan/Kislev year length type. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn cheshvan_kislev_kviah(year: i32) -> Option { + cheshvan_kislev_kviah_impl(year) + } + + /// Dart entry point: construct once and call instance methods. + #[diplomat::cfg(not(supports = free_functions))] + #[diplomat::opaque] + #[allow(dead_code)] + pub struct Calendar(u8); + + impl Calendar { + #[diplomat::attr(*, constructor)] + pub fn new() -> Box { + Box::new(Calendar(0)) + } + + pub fn gregorian_to_hebrew(&self, date: CivilDate) -> Option { + gregorian_to_hebrew_impl(date) + } + + pub fn hebrew_to_gregorian(&self, date: HebrewDate) -> Option { + hebrew_to_gregorian_impl(date) + } + + pub fn holidays_on_date( + &self, + date: CivilDate, + in_israel: bool, + use_modern_holidays: bool, + ) -> Option> { + holidays_on_date_impl(date, in_israel, use_modern_holidays) + } + + pub fn is_assur_bemelacha(&self, date: CivilDate, in_israel: bool) -> Option { + is_assur_bemelacha_impl(date, in_israel) + } + + pub fn has_candle_lighting(&self, date: CivilDate, in_israel: bool) -> Option { + has_candle_lighting_impl(date, in_israel) + } + + pub fn todays_parsha(&self, date: CivilDate, in_israel: bool) -> Option { + todays_parsha_impl(date, in_israel) + } + + pub fn special_parsha(&self, date: CivilDate, in_israel: bool) -> Option { + special_parsha_impl(date, in_israel) + } + + pub fn upcoming_parsha(&self, date: CivilDate, in_israel: bool) -> Option { + upcoming_parsha_impl(date, in_israel) + } + + pub fn days_in_hebrew_year(&self, year: i32) -> Option { + Hebrew::days_in_hebrew_year(year) + } + + pub fn days_in_hebrew_month(&self, year: i32, month: u8) -> Option { + let month = decode_hebrew_month(month)?; + Hebrew::days_in_hebrew_month(year, month) + } + + pub fn is_hebrew_leap_year(&self, year: i32) -> bool { + Hebrew::is_hebrew_leap_year(year) + } + + pub fn cheshvan_kislev_kviah(&self, year: i32) -> Option { + cheshvan_kislev_kviah_impl(year) + } + } +} diff --git a/interop/src/common.rs b/interop/src/common.rs new file mode 100644 index 0000000..99963ea --- /dev/null +++ b/interop/src/common.rs @@ -0,0 +1,587 @@ +//! Shared conversion helpers used by bridge modules (not exported over FFI directly). +#![allow(missing_docs)] + +use icu_calendar::{Date, cal::Hebrew}; +use jiff::{Timestamp, civil::Date as JiffDate, tz::TimeZone}; +use jiff_icu::ConvertTryFrom; +use kosher_rust::{ + calendar::{ + HebrewCalendarDate, YearLengthType, + holiday::Holiday, + month::{ADAR, ADARI, AV, ELUL, IYYAR, KISLEV, NISAN, SHEVAT, SIVAN, TAMMUZ, TEVET, TISHREI, ḤESHVAN}, + parsha::Parsha, + }, + limudim::{Side, Tractate}, + zmanim::types::error::ZmanimError, +}; +use num_enum::{IntoPrimitive, TryFromPrimitive}; + +/// Gregorian civil date passed across the FFI boundary. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub struct CivilDate { + pub year: i32, + pub month: u8, + pub day: u8, +} + +/// Hebrew calendar date passed across the FFI boundary. +/// +/// Month codes follow ICU Hebrew month numbering used in this crate: +/// 1 = Tishrei … 12 = Elul, and 25 = Adar I (leap years only). +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub struct HebrewDate { + pub year: i32, + pub month: u8, + pub day: u8, +} + +pub fn civil_date_to_jiff(date: CivilDate) -> Option { + JiffDate::new( + i16::try_from(date.year).ok()?, + i8::try_from(date.month).ok()?, + i8::try_from(date.day).ok()?, + ) + .ok() +} + +pub fn jiff_to_civil_date(date: JiffDate) -> CivilDate { + CivilDate { + year: i32::from(date.year()), + month: u8::try_from(date.month()).unwrap_or(0), + day: u8::try_from(date.day()).unwrap_or(0), + } +} + +pub fn encode_hebrew_month(month: icu_calendar::types::Month) -> u8 { + if month == ADARI { + 25 + } else if month == TISHREI { + 1 + } else if month == ḤESHVAN { + 2 + } else if month == KISLEV { + 3 + } else if month == TEVET { + 4 + } else if month == SHEVAT { + 5 + } else if month == ADAR { + 6 + } else if month == NISAN { + 7 + } else if month == IYYAR { + 8 + } else if month == SIVAN { + 9 + } else if month == TAMMUZ { + 10 + } else if month == AV { + 11 + } else if month == ELUL { + 12 + } else { + 0 + } +} + +pub fn decode_hebrew_month(code: u8) -> Option { + match code { + 1 => Some(TISHREI), + 2 => Some(ḤESHVAN), + 3 => Some(KISLEV), + 4 => Some(TEVET), + 5 => Some(SHEVAT), + 6 => Some(ADAR), + 7 => Some(NISAN), + 8 => Some(IYYAR), + 9 => Some(SIVAN), + 10 => Some(TAMMUZ), + 11 => Some(AV), + 12 => Some(ELUL), + 25 => Some(ADARI), + _ => None, + } +} + +pub fn gregorian_to_hebrew(date: CivilDate) -> Option { + let jiff = civil_date_to_jiff(date)?; + let hebrew = jiff.hebrew_date(); + Some(HebrewDate { + year: hebrew.year().extended_year(), + month: encode_hebrew_month(hebrew.month().to_input()), + day: hebrew.day_of_month().0, + }) +} + +pub fn hebrew_to_gregorian(date: HebrewDate) -> Option { + let month = decode_hebrew_month(date.month)?; + let hebrew = Date::try_new_hebrew_v2(date.year, month, date.day).ok()?; + let iso: Date = hebrew.to_calendar(icu_calendar::cal::Iso); + let jiff = JiffDate::convert_try_from(iso).ok()?; + Some(jiff_to_civil_date(jiff)) +} + +pub fn hebrew_date_from_civil(date: CivilDate) -> Option> { + let jiff = civil_date_to_jiff(date)?; + Some(jiff.hebrew_date()) +} + +pub fn parse_timezone(iana: &str) -> Option { + if iana.is_empty() { + return None; + } + TimeZone::get(iana).ok() +} + +pub fn timestamp_to_epoch_ms(timestamp: Timestamp) -> i64 { + timestamp.as_millisecond() +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq, IntoPrimitive, TryFromPrimitive)] +#[repr(u8)] +pub enum ZmanimErrorCode { + InvalidLatitude = 0, + InvalidLongitude = 1, + InvalidElevation = 2, + TimeZoneRequired = 3, + CalculationError = 4, + AllDay = 5, + AllNight = 6, + TimeConversionError = 7, + InvalidForDate = 8, + InvalidHours = 9, +} + +impl From for ZmanimErrorCode { + fn from(error: ZmanimError) -> Self { + match error { + ZmanimError::InvalidLatitude => Self::InvalidLatitude, + ZmanimError::InvalidLongitude => Self::InvalidLongitude, + ZmanimError::InvalidElevation => Self::InvalidElevation, + ZmanimError::TimeZoneRequired => Self::TimeZoneRequired, + ZmanimError::CalculationError => Self::CalculationError, + ZmanimError::AllDay => Self::AllDay, + ZmanimError::AllNight => Self::AllNight, + ZmanimError::TimeConversionError => Self::TimeConversionError, + ZmanimError::InvalidForDate => Self::InvalidForDate, + ZmanimError::InvalidHours => Self::InvalidHours, + } + } +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq, IntoPrimitive, TryFromPrimitive)] +#[repr(u8)] +pub enum YearLengthTypeCode { + Chaserim = 0, + Kesidran = 1, + Shelaimim = 2, +} + +impl From for YearLengthTypeCode { + fn from(value: YearLengthType) -> Self { + match value { + YearLengthType::Chaserim => Self::Chaserim, + YearLengthType::Kesidran => Self::Kesidran, + YearLengthType::Shelaimim => Self::Shelaimim, + } + } +} + +pub fn holiday_to_codes(holiday: Holiday) -> (HolidayCode, u8) { + match holiday { + Holiday::ErevPesach => (HolidayCode::ErevPesach, 0), + Holiday::Pesach => (HolidayCode::Pesach, 0), + Holiday::CholHamoedPesach => (HolidayCode::CholHamoedPesach, 0), + Holiday::PesachSheni => (HolidayCode::PesachSheni, 0), + Holiday::ErevShavuos => (HolidayCode::ErevShavuos, 0), + Holiday::Shavuos => (HolidayCode::Shavuos, 0), + Holiday::SeventeenthOfTammuz => (HolidayCode::SeventeenthOfTammuz, 0), + Holiday::TishahBav => (HolidayCode::TishahBav, 0), + Holiday::TuBav => (HolidayCode::TuBav, 0), + Holiday::ErevRoshHashana => (HolidayCode::ErevRoshHashana, 0), + Holiday::RoshHashana => (HolidayCode::RoshHashana, 0), + Holiday::FastOfGedalyah => (HolidayCode::FastOfGedalyah, 0), + Holiday::ErevYomKippur => (HolidayCode::ErevYomKippur, 0), + Holiday::YomKippur => (HolidayCode::YomKippur, 0), + Holiday::ErevSuccos => (HolidayCode::ErevSuccos, 0), + Holiday::Succos => (HolidayCode::Succos, 0), + Holiday::CholHamoedSuccos => (HolidayCode::CholHamoedSuccos, 0), + Holiday::HoshanaRabbah => (HolidayCode::HoshanaRabbah, 0), + Holiday::SheminiAtzeres => (HolidayCode::SheminiAtzeres, 0), + Holiday::SimchasTorah => (HolidayCode::SimchasTorah, 0), + Holiday::Chanukah(day) => (HolidayCode::Chanukah, day), + Holiday::TenthOfTeves => (HolidayCode::TenthOfTeves, 0), + Holiday::TuBshvat => (HolidayCode::TuBshvat, 0), + Holiday::FastOfEsther => (HolidayCode::FastOfEsther, 0), + Holiday::Purim => (HolidayCode::Purim, 0), + Holiday::ShushanPurim => (HolidayCode::ShushanPurim, 0), + Holiday::PurimKatan => (HolidayCode::PurimKatan, 0), + Holiday::RoshChodesh => (HolidayCode::RoshChodesh, 0), + Holiday::YomHaShoah => (HolidayCode::YomHaShoah, 0), + Holiday::YomHazikaron => (HolidayCode::YomHazikaron, 0), + Holiday::YomHaatzmaut => (HolidayCode::YomHaatzmaut, 0), + Holiday::YomYerushalayim => (HolidayCode::YomYerushalayim, 0), + Holiday::LagBomer => (HolidayCode::LagBomer, 0), + Holiday::ShushanPurimKatan => (HolidayCode::ShushanPurimKatan, 0), + Holiday::IsruChag => (HolidayCode::IsruChag, 0), + Holiday::YomKippurKatan => (HolidayCode::YomKippurKatan, 0), + Holiday::Behab => (HolidayCode::Behab, 0), + Holiday::FastOfTheFirstborn => (HolidayCode::FastOfTheFirstborn, 0), + Holiday::CountOfTheOmer(day) => (HolidayCode::CountOfTheOmer, day), + Holiday::BirchasHachamah => (HolidayCode::BirchasHachamah, 0), + Holiday::MacharHachodesh => (HolidayCode::MacharHachodesh, 0), + Holiday::ShabbosMevarchim => (HolidayCode::ShabbosMevarchim, 0), + } +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq, IntoPrimitive, TryFromPrimitive)] +#[repr(u16)] +pub enum HolidayCode { + ErevPesach = 0, + Pesach = 1, + CholHamoedPesach = 2, + PesachSheni = 3, + ErevShavuos = 4, + Shavuos = 5, + SeventeenthOfTammuz = 6, + TishahBav = 7, + TuBav = 8, + ErevRoshHashana = 9, + RoshHashana = 10, + FastOfGedalyah = 11, + ErevYomKippur = 12, + YomKippur = 13, + ErevSuccos = 14, + Succos = 15, + CholHamoedSuccos = 16, + HoshanaRabbah = 17, + SheminiAtzeres = 18, + SimchasTorah = 19, + Chanukah = 20, + TenthOfTeves = 21, + TuBshvat = 22, + FastOfEsther = 23, + Purim = 24, + ShushanPurim = 25, + PurimKatan = 26, + RoshChodesh = 27, + YomHaShoah = 28, + YomHazikaron = 29, + YomHaatzmaut = 30, + YomYerushalayim = 31, + LagBomer = 32, + ShushanPurimKatan = 33, + IsruChag = 34, + YomKippurKatan = 35, + Behab = 36, + FastOfTheFirstborn = 37, + CountOfTheOmer = 38, + BirchasHachamah = 39, + MacharHachodesh = 40, + ShabbosMevarchim = 41, +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq, IntoPrimitive, TryFromPrimitive)] +#[repr(u8)] +pub enum ParshaCode { + Bereshis = 0, + Noach = 1, + LechLecha = 2, + Vayera = 3, + ChayeiSara = 4, + Toldos = 5, + Vayetzei = 6, + Vayishlach = 7, + Vayeshev = 8, + Miketz = 9, + Vayigash = 10, + Vayechi = 11, + Shemos = 12, + Vaera = 13, + Bo = 14, + Beshalach = 15, + Yisro = 16, + Mishpatim = 17, + Terumah = 18, + Tetzaveh = 19, + KiSisa = 20, + Vayakhel = 21, + Pekudei = 22, + Vayikra = 23, + Tzav = 24, + Shmini = 25, + Tazria = 26, + Metzora = 27, + AchreiMos = 28, + Kedoshim = 29, + Emor = 30, + Behar = 31, + Bechukosai = 32, + Bamidbar = 33, + Nasso = 34, + Behaaloscha = 35, + Shlach = 36, + Korach = 37, + Chukas = 38, + Balak = 39, + Pinchas = 40, + Matos = 41, + Masei = 42, + Devarim = 43, + Vaeschanan = 44, + Eikev = 45, + Reeh = 46, + Shoftim = 47, + KiSeitzei = 48, + KiSavo = 49, + Nitzavim = 50, + Vayeilech = 51, + HaAzinu = 52, + VezosHabracha = 53, + VayakhelPekudei = 54, + TazriaMetzora = 55, + AchreiMosKedoshim = 56, + BeharBechukosai = 57, + ChukasBalak = 58, + MatosMasei = 59, + NitzavimVayeilech = 60, + Shekalim = 61, + Zachor = 62, + Parah = 63, + Hachodesh = 64, + Shuva = 65, + Shira = 66, + Hagadol = 67, + Chazon = 68, + Nachamu = 69, +} + +impl From for ParshaCode { + fn from(value: Parsha) -> Self { + Self::try_from(u8::from(value)).unwrap_or(Self::Bereshis) + } +} + +impl TryFrom for Parsha { + type Error = (); + + fn try_from(value: ParshaCode) -> Result { + Parsha::try_from(u8::from(value)).map_err(|_| ()) + } +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum TractateCode { + Berachos, + Peah, + Demai, + Kilayim, + Sheviis, + Terumos, + Maasros, + MaaserSheni, + Chalah, + Orlah, + Bikurim, + Shabbos, + Eruvin, + Pesachim, + Shekalim, + Yoma, + Sukkah, + Beitzah, + RoshHashanah, + Taanis, + Megillah, + MoedKatan, + Chagigah, + Yevamos, + Kesubos, + Nedarim, + Nazir, + Sotah, + Gitin, + Kiddushin, + BavaKamma, + BavaMetzia, + BavaBasra, + Sanhedrin, + Makkos, + Shevuos, + Eduyos, + AvodahZarah, + Avos, + Horiyos, + Zevachim, + Menachos, + Chullin, + Bechoros, + Arachin, + Temurah, + Kerisos, + Meilah, + Tamid, + Midos, + Kinnim, + Keilim, + Ohalos, + Negaim, + Parah, + Taharos, + Mikvaos, + Niddah, + Machshirin, + Zavim, + TevulYom, + Yadayim, + Uktzin, +} + +pub fn tractate_to_code(value: Tractate) -> TractateCode { + match value { + Tractate::Berachos => TractateCode::Berachos, + Tractate::Peah => TractateCode::Peah, + Tractate::Demai => TractateCode::Demai, + Tractate::Kilayim => TractateCode::Kilayim, + Tractate::Sheviis => TractateCode::Sheviis, + Tractate::Terumos => TractateCode::Terumos, + Tractate::Maasros => TractateCode::Maasros, + Tractate::MaaserSheni => TractateCode::MaaserSheni, + Tractate::Chalah => TractateCode::Chalah, + Tractate::Orlah => TractateCode::Orlah, + Tractate::Bikurim => TractateCode::Bikurim, + Tractate::Shabbos => TractateCode::Shabbos, + Tractate::Eruvin => TractateCode::Eruvin, + Tractate::Pesachim => TractateCode::Pesachim, + Tractate::Shekalim => TractateCode::Shekalim, + Tractate::Yoma => TractateCode::Yoma, + Tractate::Sukkah => TractateCode::Sukkah, + Tractate::Beitzah => TractateCode::Beitzah, + Tractate::RoshHashanah => TractateCode::RoshHashanah, + Tractate::Taanis => TractateCode::Taanis, + Tractate::Megillah => TractateCode::Megillah, + Tractate::MoedKatan => TractateCode::MoedKatan, + Tractate::Chagigah => TractateCode::Chagigah, + Tractate::Yevamos => TractateCode::Yevamos, + Tractate::Kesubos => TractateCode::Kesubos, + Tractate::Nedarim => TractateCode::Nedarim, + Tractate::Nazir => TractateCode::Nazir, + Tractate::Sotah => TractateCode::Sotah, + Tractate::Gitin => TractateCode::Gitin, + Tractate::Kiddushin => TractateCode::Kiddushin, + Tractate::BavaKamma => TractateCode::BavaKamma, + Tractate::BavaMetzia => TractateCode::BavaMetzia, + Tractate::BavaBasra => TractateCode::BavaBasra, + Tractate::Sanhedrin => TractateCode::Sanhedrin, + Tractate::Makkos => TractateCode::Makkos, + Tractate::Shevuos => TractateCode::Shevuos, + Tractate::Eduyos => TractateCode::Eduyos, + Tractate::AvodahZarah => TractateCode::AvodahZarah, + Tractate::Avos => TractateCode::Avos, + Tractate::Horiyos => TractateCode::Horiyos, + Tractate::Zevachim => TractateCode::Zevachim, + Tractate::Menachos => TractateCode::Menachos, + Tractate::Chullin => TractateCode::Chullin, + Tractate::Bechoros => TractateCode::Bechoros, + Tractate::Arachin => TractateCode::Arachin, + Tractate::Temurah => TractateCode::Temurah, + Tractate::Kerisos => TractateCode::Kerisos, + Tractate::Meilah => TractateCode::Meilah, + Tractate::Tamid => TractateCode::Tamid, + Tractate::Midos => TractateCode::Midos, + Tractate::Kinnim => TractateCode::Kinnim, + Tractate::Keilim => TractateCode::Keilim, + Tractate::Ohalos => TractateCode::Ohalos, + Tractate::Negaim => TractateCode::Negaim, + Tractate::Parah => TractateCode::Parah, + Tractate::Taharos => TractateCode::Taharos, + Tractate::Mikvaos => TractateCode::Mikvaos, + Tractate::Niddah => TractateCode::Niddah, + Tractate::Machshirin => TractateCode::Machshirin, + Tractate::Zavim => TractateCode::Zavim, + Tractate::TevulYom => TractateCode::TevulYom, + Tractate::Yadayim => TractateCode::Yadayim, + Tractate::Uktzin => TractateCode::Uktzin, + } +} + +pub fn code_to_tractate(value: TractateCode) -> Tractate { + match value { + TractateCode::Berachos => Tractate::Berachos, + TractateCode::Peah => Tractate::Peah, + TractateCode::Demai => Tractate::Demai, + TractateCode::Kilayim => Tractate::Kilayim, + TractateCode::Sheviis => Tractate::Sheviis, + TractateCode::Terumos => Tractate::Terumos, + TractateCode::Maasros => Tractate::Maasros, + TractateCode::MaaserSheni => Tractate::MaaserSheni, + TractateCode::Chalah => Tractate::Chalah, + TractateCode::Orlah => Tractate::Orlah, + TractateCode::Bikurim => Tractate::Bikurim, + TractateCode::Shabbos => Tractate::Shabbos, + TractateCode::Eruvin => Tractate::Eruvin, + TractateCode::Pesachim => Tractate::Pesachim, + TractateCode::Shekalim => Tractate::Shekalim, + TractateCode::Yoma => Tractate::Yoma, + TractateCode::Sukkah => Tractate::Sukkah, + TractateCode::Beitzah => Tractate::Beitzah, + TractateCode::RoshHashanah => Tractate::RoshHashanah, + TractateCode::Taanis => Tractate::Taanis, + TractateCode::Megillah => Tractate::Megillah, + TractateCode::MoedKatan => Tractate::MoedKatan, + TractateCode::Chagigah => Tractate::Chagigah, + TractateCode::Yevamos => Tractate::Yevamos, + TractateCode::Kesubos => Tractate::Kesubos, + TractateCode::Nedarim => Tractate::Nedarim, + TractateCode::Nazir => Tractate::Nazir, + TractateCode::Sotah => Tractate::Sotah, + TractateCode::Gitin => Tractate::Gitin, + TractateCode::Kiddushin => Tractate::Kiddushin, + TractateCode::BavaKamma => Tractate::BavaKamma, + TractateCode::BavaMetzia => Tractate::BavaMetzia, + TractateCode::BavaBasra => Tractate::BavaBasra, + TractateCode::Sanhedrin => Tractate::Sanhedrin, + TractateCode::Makkos => Tractate::Makkos, + TractateCode::Shevuos => Tractate::Shevuos, + TractateCode::Eduyos => Tractate::Eduyos, + TractateCode::AvodahZarah => Tractate::AvodahZarah, + TractateCode::Avos => Tractate::Avos, + TractateCode::Horiyos => Tractate::Horiyos, + TractateCode::Zevachim => Tractate::Zevachim, + TractateCode::Menachos => Tractate::Menachos, + TractateCode::Chullin => Tractate::Chullin, + TractateCode::Bechoros => Tractate::Bechoros, + TractateCode::Arachin => Tractate::Arachin, + TractateCode::Temurah => Tractate::Temurah, + TractateCode::Kerisos => Tractate::Kerisos, + TractateCode::Meilah => Tractate::Meilah, + TractateCode::Tamid => Tractate::Tamid, + TractateCode::Midos => Tractate::Midos, + TractateCode::Kinnim => Tractate::Kinnim, + TractateCode::Keilim => Tractate::Keilim, + TractateCode::Ohalos => Tractate::Ohalos, + TractateCode::Negaim => Tractate::Negaim, + TractateCode::Parah => Tractate::Parah, + TractateCode::Taharos => Tractate::Taharos, + TractateCode::Mikvaos => Tractate::Mikvaos, + TractateCode::Niddah => Tractate::Niddah, + TractateCode::Machshirin => Tractate::Machshirin, + TractateCode::Zavim => Tractate::Zavim, + TractateCode::TevulYom => Tractate::TevulYom, + TractateCode::Yadayim => Tractate::Yadayim, + TractateCode::Uktzin => Tractate::Uktzin, + } +} + +pub fn side_to_code(value: Side) -> SideCode { + match value { + Side::Aleph => SideCode::Aleph, + Side::Bet => SideCode::Bet, + } +} + +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum SideCode { + Aleph, + Bet, +} diff --git a/interop/src/generated/mod.rs b/interop/src/generated/mod.rs new file mode 100644 index 0000000..b8c545c --- /dev/null +++ b/interop/src/generated/mod.rs @@ -0,0 +1,3 @@ +//! Generated module root. + +pub mod preset_dispatch; diff --git a/interop/src/generated/preset_dispatch.rs b/interop/src/generated/preset_dispatch.rs new file mode 100644 index 0000000..19f34c6 --- /dev/null +++ b/interop/src/generated/preset_dispatch.rs @@ -0,0 +1,1195 @@ +//! Generated by tools/generate-interop.py. Do not edit by hand. +#![allow(missing_docs, dead_code)] + +use kosher_rust::zmanim::{ZmanPreset, ZmanType, presets}; + +/// Stable count of generated zman presets. +pub const ZMAN_PRESET_COUNT: usize = 167; + +/// Metadata for a zman preset (static strings, no closures). +pub struct PresetMetadata { + pub method_name: &'static str, + pub name: &'static str, + pub zman_type: ZmanType, + pub deprecated: bool, +} + +/// Static metadata table, indexed by preset discriminant order. +pub static PRESET_METADATA: [PresetMetadata; 167] = [ + PresetMetadata { + method_name: "getAlos120Minutes", + name: presets::ALOS_120_MINUTES.name, + zman_type: ZmanType::Alos, + deprecated: true, + }, + PresetMetadata { + method_name: "getAlos120Zmanis", + name: presets::ALOS_120_ZMANIS.name, + zman_type: ZmanType::Alos, + deprecated: true, + }, + PresetMetadata { + method_name: "getAlos16Point1Degrees", + name: presets::ALOS_16_POINT_1_DEGREES.name, + zman_type: ZmanType::Alos, + deprecated: false, + }, + PresetMetadata { + method_name: "getAlos18Degrees", + name: presets::ALOS_18_DEGREES.name, + zman_type: ZmanType::Alos, + deprecated: false, + }, + PresetMetadata { + method_name: "getAlos19Degrees", + name: presets::ALOS_19_DEGREES.name, + zman_type: ZmanType::Alos, + deprecated: false, + }, + PresetMetadata { + method_name: "getAlos19Point8Degrees", + name: presets::ALOS_19_POINT_8_DEGREES.name, + zman_type: ZmanType::Alos, + deprecated: false, + }, + PresetMetadata { + method_name: "getAlos26Degrees", + name: presets::ALOS_26_DEGREES.name, + zman_type: ZmanType::Alos, + deprecated: true, + }, + PresetMetadata { + method_name: "getAlos60Minutes", + name: presets::ALOS_60_MINUTES.name, + zman_type: ZmanType::Alos, + deprecated: false, + }, + PresetMetadata { + method_name: "getAlos72Minutes", + name: presets::ALOS_72_MINUTES.name, + zman_type: ZmanType::Alos, + deprecated: false, + }, + PresetMetadata { + method_name: "getAlos72Zmanis", + name: presets::ALOS_72_ZMANIS.name, + zman_type: ZmanType::Alos, + deprecated: false, + }, + PresetMetadata { + method_name: "getAlos90Minutes", + name: presets::ALOS_90_MINUTES.name, + zman_type: ZmanType::Alos, + deprecated: false, + }, + PresetMetadata { + method_name: "getAlos90Zmanis", + name: presets::ALOS_90_ZMANIS.name, + zman_type: ZmanType::Alos, + deprecated: false, + }, + PresetMetadata { + method_name: "getAlos96Minutes", + name: presets::ALOS_96_MINUTES.name, + zman_type: ZmanType::Alos, + deprecated: false, + }, + PresetMetadata { + method_name: "getAlos96Zmanis", + name: presets::ALOS_96_ZMANIS.name, + zman_type: ZmanType::Alos, + deprecated: false, + }, + PresetMetadata { + method_name: "getAlosBaalHatanya", + name: presets::ALOS_BAAL_HATANYA.name, + zman_type: ZmanType::Alos, + deprecated: false, + }, + PresetMetadata { + method_name: "getBainHashmashosRT13Point24Degrees", + name: presets::BAIN_HASHMASHOS_RT_13_POINT_24_DEGREES.name, + zman_type: ZmanType::BeinHashmashos, + deprecated: false, + }, + PresetMetadata { + method_name: "getBainHashmashosRT13Point5MinutesBefore7Point083Degrees", + name: presets::BAIN_HASHMASHOS_RT_13_POINT_5_MINUTES_BEFORE_7_POINT_083_DEGREES.name, + zman_type: ZmanType::BeinHashmashos, + deprecated: false, + }, + PresetMetadata { + method_name: "getBainHashmashosRT2Stars", + name: presets::BAIN_HASHMASHOS_RT_2_STARS.name, + zman_type: ZmanType::BeinHashmashos, + deprecated: false, + }, + PresetMetadata { + method_name: "getBainHashmashosRT58Point5Minutes", + name: presets::BAIN_HASHMASHOS_RT_58_POINT_5_MINUTES.name, + zman_type: ZmanType::BeinHashmashos, + deprecated: false, + }, + PresetMetadata { + method_name: "getBainHashmashosYereim13Point5Minutes", + name: presets::BAIN_HASHMASHOS_YEREIM_13_POINT_5_MINUTES.name, + zman_type: ZmanType::BeinHashmashos, + deprecated: false, + }, + PresetMetadata { + method_name: "getBainHashmashosYereim16Point875Minutes", + name: presets::BAIN_HASHMASHOS_YEREIM_16_POINT_875_MINUTES.name, + zman_type: ZmanType::BeinHashmashos, + deprecated: false, + }, + PresetMetadata { + method_name: "getBainHashmashosYereim18Minutes", + name: presets::BAIN_HASHMASHOS_YEREIM_18_MINUTES.name, + zman_type: ZmanType::BeinHashmashos, + deprecated: false, + }, + PresetMetadata { + method_name: "getBainHashmashosYereim2Point1Degrees", + name: presets::BAIN_HASHMASHOS_YEREIM_2_POINT_1_DEGREES.name, + zman_type: ZmanType::BeinHashmashos, + deprecated: false, + }, + PresetMetadata { + method_name: "getBainHashmashosYereim2Point8Degrees", + name: presets::BAIN_HASHMASHOS_YEREIM_2_POINT_8_DEGREES.name, + zman_type: ZmanType::BeinHashmashos, + deprecated: false, + }, + PresetMetadata { + method_name: "getBainHashmashosYereim3Point05Degrees", + name: presets::BAIN_HASHMASHOS_YEREIM_3_POINT_05_DEGREES.name, + zman_type: ZmanType::BeinHashmashos, + deprecated: false, + }, + PresetMetadata { + method_name: "getBeginAstronomicalTwilight", + name: presets::BEGIN_ASTRONOMICAL_TWILIGHT.name, + zman_type: ZmanType::Twilight, + deprecated: false, + }, + PresetMetadata { + method_name: "getBeginCivilTwilight", + name: presets::BEGIN_CIVIL_TWILIGHT.name, + zman_type: ZmanType::Twilight, + deprecated: false, + }, + PresetMetadata { + method_name: "getBeginNauticalTwilight", + name: presets::BEGIN_NAUTICAL_TWILIGHT.name, + zman_type: ZmanType::Twilight, + deprecated: false, + }, + PresetMetadata { + method_name: "getCandleLighting", + name: presets::CANDLE_LIGHTING.name, + zman_type: ZmanType::CandleLighting, + deprecated: false, + }, + PresetMetadata { + method_name: "getChatzosHalayla", + name: presets::CHATZOS_HALAYLA.name, + zman_type: ZmanType::ChatzosHalayla, + deprecated: false, + }, + PresetMetadata { + method_name: "getChatzosHayom", + name: presets::CHATZOS_HAYOM.name, + zman_type: ZmanType::ChatzosHayom, + deprecated: false, + }, + PresetMetadata { + method_name: "getChatzosHayomAsHalfDay", + name: presets::CHATZOS_HAYOM_AS_HALF_DAY.name, + zman_type: ZmanType::ChatzosHayom, + deprecated: false, + }, + PresetMetadata { + method_name: "getSunrise", + name: presets::ELEVATION_ADJUSTED_SUNRISE.name, + zman_type: ZmanType::Netz, + deprecated: false, + }, + PresetMetadata { + method_name: "getSunset", + name: presets::ELEVATION_ADJUSTED_SUNSET.name, + zman_type: ZmanType::Shkiya, + deprecated: false, + }, + PresetMetadata { + method_name: "getEndAstronomicalTwilight", + name: presets::END_ASTRONOMICAL_TWILIGHT.name, + zman_type: ZmanType::Twilight, + deprecated: false, + }, + PresetMetadata { + method_name: "getEndCivilTwilight", + name: presets::END_CIVIL_TWILIGHT.name, + zman_type: ZmanType::Twilight, + deprecated: false, + }, + PresetMetadata { + method_name: "getEndNauticalTwilight", + name: presets::END_NAUTICAL_TWILIGHT.name, + zman_type: ZmanType::Twilight, + deprecated: false, + }, + PresetMetadata { + method_name: "getFixedLocalChatzosHayom", + name: presets::FIXED_LOCAL_CHATZOS_HAYOM.name, + zman_type: ZmanType::ChatzosHayom, + deprecated: false, + }, + PresetMetadata { + method_name: "getMinchaGedola16Point1Degrees", + name: presets::MINCHA_GEDOLA_16_POINT_1_DEGREES.name, + zman_type: ZmanType::MinchaGedola, + deprecated: false, + }, + PresetMetadata { + method_name: "getMinchaGedola30Minutes", + name: presets::MINCHA_GEDOLA_30_MINUTES.name, + zman_type: ZmanType::MinchaGedola, + deprecated: false, + }, + PresetMetadata { + method_name: "getMinchaGedola72Minutes", + name: presets::MINCHA_GEDOLA_72_MINUTES.name, + zman_type: ZmanType::MinchaGedola, + deprecated: false, + }, + PresetMetadata { + method_name: "getMinchaGedolaAhavatShalom", + name: presets::MINCHA_GEDOLA_AHAVAT_SHALOM.name, + zman_type: ZmanType::MinchaGedola, + deprecated: false, + }, + PresetMetadata { + method_name: "getMinchaGedolaAteretTorah", + name: presets::MINCHA_GEDOLA_ATERET_TORAH.name, + zman_type: ZmanType::MinchaGedola, + deprecated: false, + }, + PresetMetadata { + method_name: "getMinchaGedolaBaalHatanya", + name: presets::MINCHA_GEDOLA_BAAL_HATANYA.name, + zman_type: ZmanType::MinchaGedola, + deprecated: false, + }, + PresetMetadata { + method_name: "getMinchaGedolaGRA", + name: presets::MINCHA_GEDOLA_GRA.name, + zman_type: ZmanType::MinchaGedola, + deprecated: false, + }, + PresetMetadata { + method_name: "getMinchaGedolaGRAFixedLocalChatzos30Minutes", + name: presets::MINCHA_GEDOLA_GRAFIXED_LOCAL_CHATZOS_30_MINUTES.name, + zman_type: ZmanType::MinchaGedola, + deprecated: false, + }, + PresetMetadata { + method_name: "getMinchaGedolaGRAGreaterThan30", + name: presets::MINCHA_GEDOLA_GRAGREATER_THAN_30.name, + zman_type: ZmanType::MinchaGedola, + deprecated: false, + }, + PresetMetadata { + method_name: "getMinchaKetana16Point1Degrees", + name: presets::MINCHA_KETANA_16_POINT_1_DEGREES.name, + zman_type: ZmanType::MinchaKetana, + deprecated: false, + }, + PresetMetadata { + method_name: "getMinchaKetana72Minutes", + name: presets::MINCHA_KETANA_72_MINUTES.name, + zman_type: ZmanType::MinchaKetana, + deprecated: false, + }, + PresetMetadata { + method_name: "getMinchaKetanaAhavatShalom", + name: presets::MINCHA_KETANA_AHAVAT_SHALOM.name, + zman_type: ZmanType::MinchaKetana, + deprecated: false, + }, + PresetMetadata { + method_name: "getMinchaKetanaAteretTorah", + name: presets::MINCHA_KETANA_ATERET_TORAH.name, + zman_type: ZmanType::MinchaKetana, + deprecated: false, + }, + PresetMetadata { + method_name: "getMinchaKetanaBaalHatanya", + name: presets::MINCHA_KETANA_BAAL_HATANYA.name, + zman_type: ZmanType::MinchaKetana, + deprecated: false, + }, + PresetMetadata { + method_name: "getMinchaKetanaGRA", + name: presets::MINCHA_KETANA_GRA.name, + zman_type: ZmanType::MinchaKetana, + deprecated: false, + }, + PresetMetadata { + method_name: "getMinchaKetanaGRAFixedLocalChatzosToSunset", + name: presets::MINCHA_KETANA_GRAFIXED_LOCAL_CHATZOS_TO_SUNSET.name, + zman_type: ZmanType::MinchaKetana, + deprecated: false, + }, + PresetMetadata { + method_name: "getMisheyakir10Point2Degrees", + name: presets::MISHEYAKIR_10_POINT_2_DEGREES.name, + zman_type: ZmanType::Misheyakir, + deprecated: false, + }, + PresetMetadata { + method_name: "getMisheyakir11Degrees", + name: presets::MISHEYAKIR_11_DEGREES.name, + zman_type: ZmanType::Misheyakir, + deprecated: false, + }, + PresetMetadata { + method_name: "getMisheyakir11Point5Degrees", + name: presets::MISHEYAKIR_11_POINT_5_DEGREES.name, + zman_type: ZmanType::Misheyakir, + deprecated: false, + }, + PresetMetadata { + method_name: "getMisheyakir12Point85Degrees", + name: presets::MISHEYAKIR_12_POINT_85_DEGREES.name, + zman_type: ZmanType::Misheyakir, + deprecated: true, + }, + PresetMetadata { + method_name: "getMisheyakir7Point65Degrees", + name: presets::MISHEYAKIR_7_POINT_65_DEGREES.name, + zman_type: ZmanType::Misheyakir, + deprecated: false, + }, + PresetMetadata { + method_name: "getMisheyakir9Point5Degrees", + name: presets::MISHEYAKIR_9_POINT_5_DEGREES.name, + zman_type: ZmanType::Misheyakir, + deprecated: false, + }, + PresetMetadata { + method_name: "getPlagAhavatShalom", + name: presets::PLAG_AHAVAT_SHALOM.name, + zman_type: ZmanType::PlagHamincha, + deprecated: false, + }, + PresetMetadata { + method_name: "getPlagAlos16Point1DegreesToTzaisGeonim7Point083Degrees", + name: presets::PLAG_ALOS_16_POINT_1_DEGREES_TO_TZAIS_GEONIM_7_POINT_083_DEGREES.name, + zman_type: ZmanType::PlagHamincha, + deprecated: false, + }, + PresetMetadata { + method_name: "getPlagAlosToSunset", + name: presets::PLAG_ALOS_TO_SUNSET.name, + zman_type: ZmanType::PlagHamincha, + deprecated: true, + }, + PresetMetadata { + method_name: "getPlagHamincha120Minutes", + name: presets::PLAG_HAMINCHA_120_MINUTES.name, + zman_type: ZmanType::PlagHamincha, + deprecated: true, + }, + PresetMetadata { + method_name: "getPlagHamincha120MinutesZmanis", + name: presets::PLAG_HAMINCHA_120_MINUTES_ZMANIS.name, + zman_type: ZmanType::PlagHamincha, + deprecated: true, + }, + PresetMetadata { + method_name: "getPlagHamincha16Point1Degrees", + name: presets::PLAG_HAMINCHA_16_POINT_1_DEGREES.name, + zman_type: ZmanType::PlagHamincha, + deprecated: true, + }, + PresetMetadata { + method_name: "getPlagHamincha18Degrees", + name: presets::PLAG_HAMINCHA_18_DEGREES.name, + zman_type: ZmanType::PlagHamincha, + deprecated: true, + }, + PresetMetadata { + method_name: "getPlagHamincha19Point8Degrees", + name: presets::PLAG_HAMINCHA_19_POINT_8_DEGREES.name, + zman_type: ZmanType::PlagHamincha, + deprecated: true, + }, + PresetMetadata { + method_name: "getPlagHamincha26Degrees", + name: presets::PLAG_HAMINCHA_26_DEGREES.name, + zman_type: ZmanType::PlagHamincha, + deprecated: true, + }, + PresetMetadata { + method_name: "getPlagHamincha60Minutes", + name: presets::PLAG_HAMINCHA_60_MINUTES.name, + zman_type: ZmanType::PlagHamincha, + deprecated: false, + }, + PresetMetadata { + method_name: "getPlagHamincha72Minutes", + name: presets::PLAG_HAMINCHA_72_MINUTES.name, + zman_type: ZmanType::PlagHamincha, + deprecated: true, + }, + PresetMetadata { + method_name: "getPlagHamincha72MinutesZmanis", + name: presets::PLAG_HAMINCHA_72_MINUTES_ZMANIS.name, + zman_type: ZmanType::PlagHamincha, + deprecated: true, + }, + PresetMetadata { + method_name: "getPlagHamincha90Minutes", + name: presets::PLAG_HAMINCHA_90_MINUTES.name, + zman_type: ZmanType::PlagHamincha, + deprecated: true, + }, + PresetMetadata { + method_name: "getPlagHamincha90MinutesZmanis", + name: presets::PLAG_HAMINCHA_90_MINUTES_ZMANIS.name, + zman_type: ZmanType::PlagHamincha, + deprecated: true, + }, + PresetMetadata { + method_name: "getPlagHamincha96Minutes", + name: presets::PLAG_HAMINCHA_96_MINUTES.name, + zman_type: ZmanType::PlagHamincha, + deprecated: true, + }, + PresetMetadata { + method_name: "getPlagHamincha96MinutesZmanis", + name: presets::PLAG_HAMINCHA_96_MINUTES_ZMANIS.name, + zman_type: ZmanType::PlagHamincha, + deprecated: true, + }, + PresetMetadata { + method_name: "getPlagHaminchaAteretTorah", + name: presets::PLAG_HAMINCHA_ATERET_TORAH.name, + zman_type: ZmanType::PlagHamincha, + deprecated: false, + }, + PresetMetadata { + method_name: "getPlagHaminchaBaalHatanya", + name: presets::PLAG_HAMINCHA_BAAL_HATANYA.name, + zman_type: ZmanType::PlagHamincha, + deprecated: false, + }, + PresetMetadata { + method_name: "getPlagHaminchaGRA", + name: presets::PLAG_HAMINCHA_GRA.name, + zman_type: ZmanType::PlagHamincha, + deprecated: false, + }, + PresetMetadata { + method_name: "getPlagHaminchaGRAFixedLocalChatzosToSunset", + name: presets::PLAG_HAMINCHA_GRAFIXED_LOCAL_CHATZOS_TO_SUNSET.name, + zman_type: ZmanType::PlagHamincha, + deprecated: false, + }, + PresetMetadata { + method_name: "getPolarSunriseBenIshChai", + name: presets::POLAR_SUNRISE_BEN_ISH_CHAI.name, + zman_type: ZmanType::Netz, + deprecated: false, + }, + PresetMetadata { + method_name: "getPolarSunsetBenIshChai", + name: presets::POLAR_SUNSET_BEN_ISH_CHAI.name, + zman_type: ZmanType::Shkiya, + deprecated: false, + }, + PresetMetadata { + method_name: "getSamuchLeMinchaKetana16Point1Degrees", + name: presets::SAMUCH_LE_MINCHA_KETANA_16_POINT_1_DEGREES.name, + zman_type: ZmanType::SamuchLeMinchaKetana, + deprecated: false, + }, + PresetMetadata { + method_name: "getSamuchLeMinchaKetana72Minutes", + name: presets::SAMUCH_LE_MINCHA_KETANA_72_MINUTES.name, + zman_type: ZmanType::SamuchLeMinchaKetana, + deprecated: false, + }, + PresetMetadata { + method_name: "getSamuchLeMinchaKetanaGRA", + name: presets::SAMUCH_LE_MINCHA_KETANA_GRA.name, + zman_type: ZmanType::SamuchLeMinchaKetana, + deprecated: false, + }, + PresetMetadata { + method_name: "getSeaLevelSunrise", + name: presets::SEA_LEVEL_SUNRISE.name, + zman_type: ZmanType::Netz, + deprecated: false, + }, + PresetMetadata { + method_name: "getSeaLevelSunset", + name: presets::SEA_LEVEL_SUNSET.name, + zman_type: ZmanType::Shkiya, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanAchilasChametzBaalHatanya", + name: presets::SOF_ZMAN_ACHILAS_CHAMETZ_BAAL_HATANYA.name, + zman_type: ZmanType::SofZmanAchilasChametz, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanAchilasChametzGRA", + name: presets::SOF_ZMAN_ACHILAS_CHAMETZ_GRA.name, + zman_type: ZmanType::SofZmanAchilasChametz, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanAchilasChametzMGA16Point1Degrees", + name: presets::SOF_ZMAN_ACHILAS_CHAMETZ_MGA_16_POINT_1_DEGREES.name, + zman_type: ZmanType::SofZmanAchilasChametz, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanAchilasChametzMGA72Minutes", + name: presets::SOF_ZMAN_ACHILAS_CHAMETZ_MGA_72_MINUTES.name, + zman_type: ZmanType::SofZmanAchilasChametz, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanAchilasChametzMGA72MinutesZmanis", + name: presets::SOF_ZMAN_ACHILAS_CHAMETZ_MGA_72_MINUTES_ZMANIS.name, + zman_type: ZmanType::SofZmanAchilasChametz, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanBiurChametzBaalHatanya", + name: presets::SOF_ZMAN_BIUR_CHAMETZ_BAAL_HATANYA.name, + zman_type: ZmanType::SofZmanBiurChametz, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanBiurChametzGRA", + name: presets::SOF_ZMAN_BIUR_CHAMETZ_GRA.name, + zman_type: ZmanType::SofZmanBiurChametz, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanBiurChametzMGA16Point1Degrees", + name: presets::SOF_ZMAN_BIUR_CHAMETZ_MGA_16_POINT_1_DEGREES.name, + zman_type: ZmanType::SofZmanBiurChametz, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanBiurChametzMGA72Minutes", + name: presets::SOF_ZMAN_BIUR_CHAMETZ_MGA_72_MINUTES.name, + zman_type: ZmanType::SofZmanBiurChametz, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanBiurChametzMGA72MinutesZmanis", + name: presets::SOF_ZMAN_BIUR_CHAMETZ_MGA_72_MINUTES_ZMANIS.name, + zman_type: ZmanType::SofZmanBiurChametz, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanKidushLevana15Days", + name: presets::SOF_ZMAN_KIDUSH_LEVANA_15_DAYS.name, + zman_type: ZmanType::KidushLevana, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanKidushLevanaBetweenMoldos", + name: presets::SOF_ZMAN_KIDUSH_LEVANA_BETWEEN_MOLDOS.name, + zman_type: ZmanType::KidushLevana, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShma3HoursBeforeChatzos", + name: presets::SOF_ZMAN_SHMA_3_HOURS_BEFORE_CHATZOS.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaAlos16Point1DegreesToTzaisGeonim7Point083Degrees", + name: presets::SOF_ZMAN_SHMA_ALOS_16_POINT_1_DEGREES_TO_TZAIS_GEONIM_7_POINT_083_DEGREES.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaAlos16Point1ToSunset", + name: presets::SOF_ZMAN_SHMA_ALOS_16_POINT_1_TO_SUNSET.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaAteretTorah", + name: presets::SOF_ZMAN_SHMA_ATERET_TORAH.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaBaalHatanya", + name: presets::SOF_ZMAN_SHMA_BAAL_HATANYA.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaGRA", + name: presets::SOF_ZMAN_SHMA_GRA.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaGRASunriseToFixedLocalChatzos", + name: presets::SOF_ZMAN_SHMA_GRASUNRISE_TO_FIXED_LOCAL_CHATZOS.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaMGA120Minutes", + name: presets::SOF_ZMAN_SHMA_MGA_120_MINUTES.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaMGA16Point1Degrees", + name: presets::SOF_ZMAN_SHMA_MGA_16_POINT_1_DEGREES.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaMGA16Point1DegreesToFixedLocalChatzos", + name: presets::SOF_ZMAN_SHMA_MGA_16_POINT_1_DEGREES_TO_FIXED_LOCAL_CHATZOS.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaMGA18Degrees", + name: presets::SOF_ZMAN_SHMA_MGA_18_DEGREES.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaMGA18DegreesToFixedLocalChatzos", + name: presets::SOF_ZMAN_SHMA_MGA_18_DEGREES_TO_FIXED_LOCAL_CHATZOS.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaMGA19Point8Degrees", + name: presets::SOF_ZMAN_SHMA_MGA_19_POINT_8_DEGREES.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaMGA72Minutes", + name: presets::SOF_ZMAN_SHMA_MGA_72_MINUTES.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaMGA72MinutesToFixedLocalChatzos", + name: presets::SOF_ZMAN_SHMA_MGA_72_MINUTES_TO_FIXED_LOCAL_CHATZOS.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaMGA72MinutesZmanis", + name: presets::SOF_ZMAN_SHMA_MGA_72_MINUTES_ZMANIS.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaMGA90Minutes", + name: presets::SOF_ZMAN_SHMA_MGA_90_MINUTES.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaMGA90MinutesToFixedLocalChatzos", + name: presets::SOF_ZMAN_SHMA_MGA_90_MINUTES_TO_FIXED_LOCAL_CHATZOS.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaMGA90MinutesZmanis", + name: presets::SOF_ZMAN_SHMA_MGA_90_MINUTES_ZMANIS.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaMGA96Minutes", + name: presets::SOF_ZMAN_SHMA_MGA_96_MINUTES.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanShmaMGA96MinutesZmanis", + name: presets::SOF_ZMAN_SHMA_MGA_96_MINUTES_ZMANIS.name, + zman_type: ZmanType::SofZmanShma, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanTfila2HoursBeforeChatzos", + name: presets::SOF_ZMAN_TFILA_2_HOURS_BEFORE_CHATZOS.name, + zman_type: ZmanType::SofZmanTefila, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanTfilaAteretTorah", + name: presets::SOF_ZMAN_TFILA_ATERET_TORAH.name, + zman_type: ZmanType::SofZmanTefila, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanTfilaBaalHatanya", + name: presets::SOF_ZMAN_TFILA_BAAL_HATANYA.name, + zman_type: ZmanType::SofZmanTefila, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanTfilaGRA", + name: presets::SOF_ZMAN_TFILA_GRA.name, + zman_type: ZmanType::SofZmanTefila, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanTfilaGRASunriseToFixedLocalChatzos", + name: presets::SOF_ZMAN_TFILA_GRASUNRISE_TO_FIXED_LOCAL_CHATZOS.name, + zman_type: ZmanType::SofZmanTefila, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanTfilaMGA120Minutes", + name: presets::SOF_ZMAN_TFILA_MGA_120_MINUTES.name, + zman_type: ZmanType::SofZmanTefila, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanTfilaMGA16Point1Degrees", + name: presets::SOF_ZMAN_TFILA_MGA_16_POINT_1_DEGREES.name, + zman_type: ZmanType::SofZmanTefila, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanTfilaMGA18Degrees", + name: presets::SOF_ZMAN_TFILA_MGA_18_DEGREES.name, + zman_type: ZmanType::SofZmanTefila, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanTfilaMGA19Point8Degrees", + name: presets::SOF_ZMAN_TFILA_MGA_19_POINT_8_DEGREES.name, + zman_type: ZmanType::SofZmanTefila, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanTfilaMGA72Minutes", + name: presets::SOF_ZMAN_TFILA_MGA_72_MINUTES.name, + zman_type: ZmanType::SofZmanTefila, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanTfilaMGA72MinutesZmanis", + name: presets::SOF_ZMAN_TFILA_MGA_72_MINUTES_ZMANIS.name, + zman_type: ZmanType::SofZmanTefila, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanTfilaMGA90Minutes", + name: presets::SOF_ZMAN_TFILA_MGA_90_MINUTES.name, + zman_type: ZmanType::SofZmanTefila, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanTfilaMGA90MinutesZmanis", + name: presets::SOF_ZMAN_TFILA_MGA_90_MINUTES_ZMANIS.name, + zman_type: ZmanType::SofZmanTefila, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanTfilaMGA96Minutes", + name: presets::SOF_ZMAN_TFILA_MGA_96_MINUTES.name, + zman_type: ZmanType::SofZmanTefila, + deprecated: false, + }, + PresetMetadata { + method_name: "getSofZmanTfilaMGA96MinutesZmanis", + name: presets::SOF_ZMAN_TFILA_MGA_96_MINUTES_ZMANIS.name, + zman_type: ZmanType::SofZmanTefila, + deprecated: false, + }, + PresetMetadata { + method_name: "getSolarMidnight", + name: presets::SOLAR_MIDNIGHT.name, + zman_type: ZmanType::ChatzosHalayla, + deprecated: false, + }, + PresetMetadata { + method_name: "getSunTransit", + name: presets::SUN_TRANSIT.name, + zman_type: ZmanType::ChatzosHayom, + deprecated: false, + }, + PresetMetadata { + method_name: "getTchilasZmanKidushLevana3Days", + name: presets::TCHILAS_ZMAN_KIDUSH_LEVANA_3_DAYS.name, + zman_type: ZmanType::KidushLevana, + deprecated: false, + }, + PresetMetadata { + method_name: "getTchilasZmanKidushLevana7Days", + name: presets::TCHILAS_ZMAN_KIDUSH_LEVANA_7_DAYS.name, + zman_type: ZmanType::KidushLevana, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzais120Minutes", + name: presets::TZAIS_120_MINUTES.name, + zman_type: ZmanType::Tzais, + deprecated: true, + }, + PresetMetadata { + method_name: "getTzais120Zmanis", + name: presets::TZAIS_120_ZMANIS.name, + zman_type: ZmanType::Tzais, + deprecated: true, + }, + PresetMetadata { + method_name: "getTzais16Point1Degrees", + name: presets::TZAIS_16_POINT_1_DEGREES.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzais18Degrees", + name: presets::TZAIS_18_DEGREES.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzais19Point8Degrees", + name: presets::TZAIS_19_POINT_8_DEGREES.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzais26Degrees", + name: presets::TZAIS_26_DEGREES.name, + zman_type: ZmanType::Tzais, + deprecated: true, + }, + PresetMetadata { + method_name: "getTzais50Minutes", + name: presets::TZAIS_50_MINUTES.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzais60Minutes", + name: presets::TZAIS_60_MINUTES.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzais72Minutes", + name: presets::TZAIS_72_MINUTES.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzais72Zmanis", + name: presets::TZAIS_72_ZMANIS.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzais90Minutes", + name: presets::TZAIS_90_MINUTES.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzais90Zmanis", + name: presets::TZAIS_90_ZMANIS.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzais96Minutes", + name: presets::TZAIS_96_MINUTES.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzais96Zmanis", + name: presets::TZAIS_96_ZMANIS.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzaisAteretTorah", + name: presets::TZAIS_ATERET_TORAH.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzaisBaalHatanya", + name: presets::TZAIS_BAAL_HATANYA.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzaisGeonim3Point7Degrees", + name: presets::TZAIS_GEONIM_3_POINT_7_DEGREES.name, + zman_type: ZmanType::Tzais, + deprecated: true, + }, + PresetMetadata { + method_name: "getTzaisGeonim3Point8Degrees", + name: presets::TZAIS_GEONIM_3_POINT_8_DEGREES.name, + zman_type: ZmanType::Tzais, + deprecated: true, + }, + PresetMetadata { + method_name: "getTzaisGeonim4Point42Degrees", + name: presets::TZAIS_GEONIM_4_POINT_42_DEGREES.name, + zman_type: ZmanType::Tzais, + deprecated: true, + }, + PresetMetadata { + method_name: "getTzaisGeonim4Point66Degrees", + name: presets::TZAIS_GEONIM_4_POINT_66_DEGREES.name, + zman_type: ZmanType::Tzais, + deprecated: true, + }, + PresetMetadata { + method_name: "getTzaisGeonim4Point8Degrees", + name: presets::TZAIS_GEONIM_4_POINT_8_DEGREES.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzaisGeonim5Point95Degrees", + name: presets::TZAIS_GEONIM_5_POINT_95_DEGREES.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzaisGeonim6Point45Degrees", + name: presets::TZAIS_GEONIM_6_POINT_45_DEGREES.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzaisGeonim7Point083Degrees", + name: presets::TZAIS_GEONIM_7_POINT_083_DEGREES.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzaisGeonim7Point67Degrees", + name: presets::TZAIS_GEONIM_7_POINT_67_DEGREES.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzaisGeonim8Point5Degrees", + name: presets::TZAIS_GEONIM_8_POINT_5_DEGREES.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzaisGeonim9Point3Degrees", + name: presets::TZAIS_GEONIM_9_POINT_3_DEGREES.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, + PresetMetadata { + method_name: "getTzaisGeonim9Point75Degrees", + name: presets::TZAIS_GEONIM_9_POINT_75_DEGREES.name, + zman_type: ZmanType::Tzais, + deprecated: false, + }, +]; + +/// Looks up a preset static by stable index (matches [`ZmanPresetId`] discriminant order). +pub fn preset_by_index(index: usize) -> Option<&'static ZmanPreset> { + match index { + 0 => Some(&presets::ALOS_120_MINUTES), + 1 => Some(&presets::ALOS_120_ZMANIS), + 2 => Some(&presets::ALOS_16_POINT_1_DEGREES), + 3 => Some(&presets::ALOS_18_DEGREES), + 4 => Some(&presets::ALOS_19_DEGREES), + 5 => Some(&presets::ALOS_19_POINT_8_DEGREES), + 6 => Some(&presets::ALOS_26_DEGREES), + 7 => Some(&presets::ALOS_60_MINUTES), + 8 => Some(&presets::ALOS_72_MINUTES), + 9 => Some(&presets::ALOS_72_ZMANIS), + 10 => Some(&presets::ALOS_90_MINUTES), + 11 => Some(&presets::ALOS_90_ZMANIS), + 12 => Some(&presets::ALOS_96_MINUTES), + 13 => Some(&presets::ALOS_96_ZMANIS), + 14 => Some(&presets::ALOS_BAAL_HATANYA), + 15 => Some(&presets::BAIN_HASHMASHOS_RT_13_POINT_24_DEGREES), + 16 => Some(&presets::BAIN_HASHMASHOS_RT_13_POINT_5_MINUTES_BEFORE_7_POINT_083_DEGREES), + 17 => Some(&presets::BAIN_HASHMASHOS_RT_2_STARS), + 18 => Some(&presets::BAIN_HASHMASHOS_RT_58_POINT_5_MINUTES), + 19 => Some(&presets::BAIN_HASHMASHOS_YEREIM_13_POINT_5_MINUTES), + 20 => Some(&presets::BAIN_HASHMASHOS_YEREIM_16_POINT_875_MINUTES), + 21 => Some(&presets::BAIN_HASHMASHOS_YEREIM_18_MINUTES), + 22 => Some(&presets::BAIN_HASHMASHOS_YEREIM_2_POINT_1_DEGREES), + 23 => Some(&presets::BAIN_HASHMASHOS_YEREIM_2_POINT_8_DEGREES), + 24 => Some(&presets::BAIN_HASHMASHOS_YEREIM_3_POINT_05_DEGREES), + 25 => Some(&presets::BEGIN_ASTRONOMICAL_TWILIGHT), + 26 => Some(&presets::BEGIN_CIVIL_TWILIGHT), + 27 => Some(&presets::BEGIN_NAUTICAL_TWILIGHT), + 28 => Some(&presets::CANDLE_LIGHTING), + 29 => Some(&presets::CHATZOS_HALAYLA), + 30 => Some(&presets::CHATZOS_HAYOM), + 31 => Some(&presets::CHATZOS_HAYOM_AS_HALF_DAY), + 32 => Some(&presets::ELEVATION_ADJUSTED_SUNRISE), + 33 => Some(&presets::ELEVATION_ADJUSTED_SUNSET), + 34 => Some(&presets::END_ASTRONOMICAL_TWILIGHT), + 35 => Some(&presets::END_CIVIL_TWILIGHT), + 36 => Some(&presets::END_NAUTICAL_TWILIGHT), + 37 => Some(&presets::FIXED_LOCAL_CHATZOS_HAYOM), + 38 => Some(&presets::MINCHA_GEDOLA_16_POINT_1_DEGREES), + 39 => Some(&presets::MINCHA_GEDOLA_30_MINUTES), + 40 => Some(&presets::MINCHA_GEDOLA_72_MINUTES), + 41 => Some(&presets::MINCHA_GEDOLA_AHAVAT_SHALOM), + 42 => Some(&presets::MINCHA_GEDOLA_ATERET_TORAH), + 43 => Some(&presets::MINCHA_GEDOLA_BAAL_HATANYA), + 44 => Some(&presets::MINCHA_GEDOLA_GRA), + 45 => Some(&presets::MINCHA_GEDOLA_GRAFIXED_LOCAL_CHATZOS_30_MINUTES), + 46 => Some(&presets::MINCHA_GEDOLA_GRAGREATER_THAN_30), + 47 => Some(&presets::MINCHA_KETANA_16_POINT_1_DEGREES), + 48 => Some(&presets::MINCHA_KETANA_72_MINUTES), + 49 => Some(&presets::MINCHA_KETANA_AHAVAT_SHALOM), + 50 => Some(&presets::MINCHA_KETANA_ATERET_TORAH), + 51 => Some(&presets::MINCHA_KETANA_BAAL_HATANYA), + 52 => Some(&presets::MINCHA_KETANA_GRA), + 53 => Some(&presets::MINCHA_KETANA_GRAFIXED_LOCAL_CHATZOS_TO_SUNSET), + 54 => Some(&presets::MISHEYAKIR_10_POINT_2_DEGREES), + 55 => Some(&presets::MISHEYAKIR_11_DEGREES), + 56 => Some(&presets::MISHEYAKIR_11_POINT_5_DEGREES), + 57 => Some(&presets::MISHEYAKIR_12_POINT_85_DEGREES), + 58 => Some(&presets::MISHEYAKIR_7_POINT_65_DEGREES), + 59 => Some(&presets::MISHEYAKIR_9_POINT_5_DEGREES), + 60 => Some(&presets::PLAG_AHAVAT_SHALOM), + 61 => Some(&presets::PLAG_ALOS_16_POINT_1_DEGREES_TO_TZAIS_GEONIM_7_POINT_083_DEGREES), + 62 => Some(&presets::PLAG_ALOS_TO_SUNSET), + 63 => Some(&presets::PLAG_HAMINCHA_120_MINUTES), + 64 => Some(&presets::PLAG_HAMINCHA_120_MINUTES_ZMANIS), + 65 => Some(&presets::PLAG_HAMINCHA_16_POINT_1_DEGREES), + 66 => Some(&presets::PLAG_HAMINCHA_18_DEGREES), + 67 => Some(&presets::PLAG_HAMINCHA_19_POINT_8_DEGREES), + 68 => Some(&presets::PLAG_HAMINCHA_26_DEGREES), + 69 => Some(&presets::PLAG_HAMINCHA_60_MINUTES), + 70 => Some(&presets::PLAG_HAMINCHA_72_MINUTES), + 71 => Some(&presets::PLAG_HAMINCHA_72_MINUTES_ZMANIS), + 72 => Some(&presets::PLAG_HAMINCHA_90_MINUTES), + 73 => Some(&presets::PLAG_HAMINCHA_90_MINUTES_ZMANIS), + 74 => Some(&presets::PLAG_HAMINCHA_96_MINUTES), + 75 => Some(&presets::PLAG_HAMINCHA_96_MINUTES_ZMANIS), + 76 => Some(&presets::PLAG_HAMINCHA_ATERET_TORAH), + 77 => Some(&presets::PLAG_HAMINCHA_BAAL_HATANYA), + 78 => Some(&presets::PLAG_HAMINCHA_GRA), + 79 => Some(&presets::PLAG_HAMINCHA_GRAFIXED_LOCAL_CHATZOS_TO_SUNSET), + 80 => Some(&presets::POLAR_SUNRISE_BEN_ISH_CHAI), + 81 => Some(&presets::POLAR_SUNSET_BEN_ISH_CHAI), + 82 => Some(&presets::SAMUCH_LE_MINCHA_KETANA_16_POINT_1_DEGREES), + 83 => Some(&presets::SAMUCH_LE_MINCHA_KETANA_72_MINUTES), + 84 => Some(&presets::SAMUCH_LE_MINCHA_KETANA_GRA), + 85 => Some(&presets::SEA_LEVEL_SUNRISE), + 86 => Some(&presets::SEA_LEVEL_SUNSET), + 87 => Some(&presets::SOF_ZMAN_ACHILAS_CHAMETZ_BAAL_HATANYA), + 88 => Some(&presets::SOF_ZMAN_ACHILAS_CHAMETZ_GRA), + 89 => Some(&presets::SOF_ZMAN_ACHILAS_CHAMETZ_MGA_16_POINT_1_DEGREES), + 90 => Some(&presets::SOF_ZMAN_ACHILAS_CHAMETZ_MGA_72_MINUTES), + 91 => Some(&presets::SOF_ZMAN_ACHILAS_CHAMETZ_MGA_72_MINUTES_ZMANIS), + 92 => Some(&presets::SOF_ZMAN_BIUR_CHAMETZ_BAAL_HATANYA), + 93 => Some(&presets::SOF_ZMAN_BIUR_CHAMETZ_GRA), + 94 => Some(&presets::SOF_ZMAN_BIUR_CHAMETZ_MGA_16_POINT_1_DEGREES), + 95 => Some(&presets::SOF_ZMAN_BIUR_CHAMETZ_MGA_72_MINUTES), + 96 => Some(&presets::SOF_ZMAN_BIUR_CHAMETZ_MGA_72_MINUTES_ZMANIS), + 97 => Some(&presets::SOF_ZMAN_KIDUSH_LEVANA_15_DAYS), + 98 => Some(&presets::SOF_ZMAN_KIDUSH_LEVANA_BETWEEN_MOLDOS), + 99 => Some(&presets::SOF_ZMAN_SHMA_3_HOURS_BEFORE_CHATZOS), + 100 => Some(&presets::SOF_ZMAN_SHMA_ALOS_16_POINT_1_DEGREES_TO_TZAIS_GEONIM_7_POINT_083_DEGREES), + 101 => Some(&presets::SOF_ZMAN_SHMA_ALOS_16_POINT_1_TO_SUNSET), + 102 => Some(&presets::SOF_ZMAN_SHMA_ATERET_TORAH), + 103 => Some(&presets::SOF_ZMAN_SHMA_BAAL_HATANYA), + 104 => Some(&presets::SOF_ZMAN_SHMA_GRA), + 105 => Some(&presets::SOF_ZMAN_SHMA_GRASUNRISE_TO_FIXED_LOCAL_CHATZOS), + 106 => Some(&presets::SOF_ZMAN_SHMA_MGA_120_MINUTES), + 107 => Some(&presets::SOF_ZMAN_SHMA_MGA_16_POINT_1_DEGREES), + 108 => Some(&presets::SOF_ZMAN_SHMA_MGA_16_POINT_1_DEGREES_TO_FIXED_LOCAL_CHATZOS), + 109 => Some(&presets::SOF_ZMAN_SHMA_MGA_18_DEGREES), + 110 => Some(&presets::SOF_ZMAN_SHMA_MGA_18_DEGREES_TO_FIXED_LOCAL_CHATZOS), + 111 => Some(&presets::SOF_ZMAN_SHMA_MGA_19_POINT_8_DEGREES), + 112 => Some(&presets::SOF_ZMAN_SHMA_MGA_72_MINUTES), + 113 => Some(&presets::SOF_ZMAN_SHMA_MGA_72_MINUTES_TO_FIXED_LOCAL_CHATZOS), + 114 => Some(&presets::SOF_ZMAN_SHMA_MGA_72_MINUTES_ZMANIS), + 115 => Some(&presets::SOF_ZMAN_SHMA_MGA_90_MINUTES), + 116 => Some(&presets::SOF_ZMAN_SHMA_MGA_90_MINUTES_TO_FIXED_LOCAL_CHATZOS), + 117 => Some(&presets::SOF_ZMAN_SHMA_MGA_90_MINUTES_ZMANIS), + 118 => Some(&presets::SOF_ZMAN_SHMA_MGA_96_MINUTES), + 119 => Some(&presets::SOF_ZMAN_SHMA_MGA_96_MINUTES_ZMANIS), + 120 => Some(&presets::SOF_ZMAN_TFILA_2_HOURS_BEFORE_CHATZOS), + 121 => Some(&presets::SOF_ZMAN_TFILA_ATERET_TORAH), + 122 => Some(&presets::SOF_ZMAN_TFILA_BAAL_HATANYA), + 123 => Some(&presets::SOF_ZMAN_TFILA_GRA), + 124 => Some(&presets::SOF_ZMAN_TFILA_GRASUNRISE_TO_FIXED_LOCAL_CHATZOS), + 125 => Some(&presets::SOF_ZMAN_TFILA_MGA_120_MINUTES), + 126 => Some(&presets::SOF_ZMAN_TFILA_MGA_16_POINT_1_DEGREES), + 127 => Some(&presets::SOF_ZMAN_TFILA_MGA_18_DEGREES), + 128 => Some(&presets::SOF_ZMAN_TFILA_MGA_19_POINT_8_DEGREES), + 129 => Some(&presets::SOF_ZMAN_TFILA_MGA_72_MINUTES), + 130 => Some(&presets::SOF_ZMAN_TFILA_MGA_72_MINUTES_ZMANIS), + 131 => Some(&presets::SOF_ZMAN_TFILA_MGA_90_MINUTES), + 132 => Some(&presets::SOF_ZMAN_TFILA_MGA_90_MINUTES_ZMANIS), + 133 => Some(&presets::SOF_ZMAN_TFILA_MGA_96_MINUTES), + 134 => Some(&presets::SOF_ZMAN_TFILA_MGA_96_MINUTES_ZMANIS), + 135 => Some(&presets::SOLAR_MIDNIGHT), + 136 => Some(&presets::SUN_TRANSIT), + 137 => Some(&presets::TCHILAS_ZMAN_KIDUSH_LEVANA_3_DAYS), + 138 => Some(&presets::TCHILAS_ZMAN_KIDUSH_LEVANA_7_DAYS), + 139 => Some(&presets::TZAIS_120_MINUTES), + 140 => Some(&presets::TZAIS_120_ZMANIS), + 141 => Some(&presets::TZAIS_16_POINT_1_DEGREES), + 142 => Some(&presets::TZAIS_18_DEGREES), + 143 => Some(&presets::TZAIS_19_POINT_8_DEGREES), + 144 => Some(&presets::TZAIS_26_DEGREES), + 145 => Some(&presets::TZAIS_50_MINUTES), + 146 => Some(&presets::TZAIS_60_MINUTES), + 147 => Some(&presets::TZAIS_72_MINUTES), + 148 => Some(&presets::TZAIS_72_ZMANIS), + 149 => Some(&presets::TZAIS_90_MINUTES), + 150 => Some(&presets::TZAIS_90_ZMANIS), + 151 => Some(&presets::TZAIS_96_MINUTES), + 152 => Some(&presets::TZAIS_96_ZMANIS), + 153 => Some(&presets::TZAIS_ATERET_TORAH), + 154 => Some(&presets::TZAIS_BAAL_HATANYA), + 155 => Some(&presets::TZAIS_GEONIM_3_POINT_7_DEGREES), + 156 => Some(&presets::TZAIS_GEONIM_3_POINT_8_DEGREES), + 157 => Some(&presets::TZAIS_GEONIM_4_POINT_42_DEGREES), + 158 => Some(&presets::TZAIS_GEONIM_4_POINT_66_DEGREES), + 159 => Some(&presets::TZAIS_GEONIM_4_POINT_8_DEGREES), + 160 => Some(&presets::TZAIS_GEONIM_5_POINT_95_DEGREES), + 161 => Some(&presets::TZAIS_GEONIM_6_POINT_45_DEGREES), + 162 => Some(&presets::TZAIS_GEONIM_7_POINT_083_DEGREES), + 163 => Some(&presets::TZAIS_GEONIM_7_POINT_67_DEGREES), + 164 => Some(&presets::TZAIS_GEONIM_8_POINT_5_DEGREES), + 165 => Some(&presets::TZAIS_GEONIM_9_POINT_3_DEGREES), + 166 => Some(&presets::TZAIS_GEONIM_9_POINT_75_DEGREES), + _ => None, + } +} diff --git a/interop/src/lib.rs b/interop/src/lib.rs new file mode 100644 index 0000000..75a088e --- /dev/null +++ b/interop/src/lib.rs @@ -0,0 +1,11 @@ +//! Diplomat FFI bridge for [`kosher_rust`]. +//! +//! See [`interop/README.md`](../../interop/README.md) for conventions and regeneration steps. + +mod calendar; +pub mod common; +mod limudim; +mod zman_preset; +mod zmanim; + +pub mod generated; diff --git a/interop/src/limudim.rs b/interop/src/limudim.rs new file mode 100644 index 0000000..63e2c67 --- /dev/null +++ b/interop/src/limudim.rs @@ -0,0 +1,375 @@ +//! Limudim FFI bridge. + +#[diplomat::bridge] +mod ffi { + use kosher_rust::limudim::{ + AmudYomiBavliDirshu, DafHashavuaBavli, DafYomiBavli, DafYomiYerushalmiVilna, LimudCalendar, MishnaYomis, + PirkeiAvos, PirkeiAvosUnit, TehillimMonthly, TehillimUnit, + }; + + use crate::common::{TractateCode as InternalTractateCode, civil_date_to_jiff, side_to_code, tractate_to_code}; + + pub enum TractateCode { + Berachos, + Peah, + Demai, + Kilayim, + Sheviis, + Terumos, + Maasros, + MaaserSheni, + Chalah, + Orlah, + Bikurim, + Shabbos, + Eruvin, + Pesachim, + Shekalim, + Yoma, + Sukkah, + Beitzah, + RoshHashanah, + Taanis, + Megillah, + MoedKatan, + Chagigah, + Yevamos, + Kesubos, + Nedarim, + Nazir, + Sotah, + Gitin, + Kiddushin, + BavaKamma, + BavaMetzia, + BavaBasra, + Sanhedrin, + Makkos, + Shevuos, + Eduyos, + AvodahZarah, + Avos, + Horiyos, + Zevachim, + Menachos, + Chullin, + Bechoros, + Arachin, + Temurah, + Kerisos, + Meilah, + Tamid, + Midos, + Kinnim, + Keilim, + Ohalos, + Negaim, + Parah, + Taharos, + Mikvaos, + Niddah, + Machshirin, + Zavim, + TevulYom, + Yadayim, + Uktzin, + } + + pub enum SideCode { + Aleph, + Bet, + } + + pub struct DafResult { + pub tractate: TractateCode, + pub page: u16, + } + + pub struct AmudResult { + pub tractate: TractateCode, + pub page: u16, + pub side: SideCode, + } + + pub struct MishnaResult { + pub tractate: TractateCode, + pub chapter: usize, + pub mishna: u16, + } + + pub struct MishnasResult { + pub start: MishnaResult, + pub end: MishnaResult, + } + + /// Flat tagged union for Pirkei Avos (`kind`: 0 = single, 1 = combined). + pub struct PirkeiAvosResult { + pub kind: u8, + pub perek1: u8, + pub perek2: u8, + } + + /// Flat tagged union for Tehillim (`kind`: 0 = psalms range, 1 = verse range). + pub struct TehillimResult { + pub kind: u8, + pub start: u8, + pub end: u8, + pub psalm: u8, + pub start_verse: u16, + pub end_verse: u16, + } + + fn to_ffi_tractate(code: InternalTractateCode) -> TractateCode { + use InternalTractateCode as C; + match code { + C::Berachos => TractateCode::Berachos, + C::Peah => TractateCode::Peah, + C::Demai => TractateCode::Demai, + C::Kilayim => TractateCode::Kilayim, + C::Sheviis => TractateCode::Sheviis, + C::Terumos => TractateCode::Terumos, + C::Maasros => TractateCode::Maasros, + C::MaaserSheni => TractateCode::MaaserSheni, + C::Chalah => TractateCode::Chalah, + C::Orlah => TractateCode::Orlah, + C::Bikurim => TractateCode::Bikurim, + C::Shabbos => TractateCode::Shabbos, + C::Eruvin => TractateCode::Eruvin, + C::Pesachim => TractateCode::Pesachim, + C::Shekalim => TractateCode::Shekalim, + C::Yoma => TractateCode::Yoma, + C::Sukkah => TractateCode::Sukkah, + C::Beitzah => TractateCode::Beitzah, + C::RoshHashanah => TractateCode::RoshHashanah, + C::Taanis => TractateCode::Taanis, + C::Megillah => TractateCode::Megillah, + C::MoedKatan => TractateCode::MoedKatan, + C::Chagigah => TractateCode::Chagigah, + C::Yevamos => TractateCode::Yevamos, + C::Kesubos => TractateCode::Kesubos, + C::Nedarim => TractateCode::Nedarim, + C::Nazir => TractateCode::Nazir, + C::Sotah => TractateCode::Sotah, + C::Gitin => TractateCode::Gitin, + C::Kiddushin => TractateCode::Kiddushin, + C::BavaKamma => TractateCode::BavaKamma, + C::BavaMetzia => TractateCode::BavaMetzia, + C::BavaBasra => TractateCode::BavaBasra, + C::Sanhedrin => TractateCode::Sanhedrin, + C::Makkos => TractateCode::Makkos, + C::Shevuos => TractateCode::Shevuos, + C::Eduyos => TractateCode::Eduyos, + C::AvodahZarah => TractateCode::AvodahZarah, + C::Avos => TractateCode::Avos, + C::Horiyos => TractateCode::Horiyos, + C::Zevachim => TractateCode::Zevachim, + C::Menachos => TractateCode::Menachos, + C::Chullin => TractateCode::Chullin, + C::Bechoros => TractateCode::Bechoros, + C::Arachin => TractateCode::Arachin, + C::Temurah => TractateCode::Temurah, + C::Kerisos => TractateCode::Kerisos, + C::Meilah => TractateCode::Meilah, + C::Tamid => TractateCode::Tamid, + C::Midos => TractateCode::Midos, + C::Kinnim => TractateCode::Kinnim, + C::Keilim => TractateCode::Keilim, + C::Ohalos => TractateCode::Ohalos, + C::Negaim => TractateCode::Negaim, + C::Parah => TractateCode::Parah, + C::Taharos => TractateCode::Taharos, + C::Mikvaos => TractateCode::Mikvaos, + C::Niddah => TractateCode::Niddah, + C::Machshirin => TractateCode::Machshirin, + C::Zavim => TractateCode::Zavim, + C::TevulYom => TractateCode::TevulYom, + C::Yadayim => TractateCode::Yadayim, + C::Uktzin => TractateCode::Uktzin, + } + } + + fn to_ffi_side(code: crate::common::SideCode) -> SideCode { + match code { + crate::common::SideCode::Aleph => SideCode::Aleph, + crate::common::SideCode::Bet => SideCode::Bet, + } + } + + fn to_mishna_result(m: kosher_rust::limudim::Mishna) -> MishnaResult { + MishnaResult { + tractate: to_ffi_tractate(tractate_to_code(m.tractate)), + chapter: m.chapter, + mishna: m.mishna, + } + } + + fn jiff_from_parts(year: i32, month: u8, day: u8) -> Option { + civil_date_to_jiff(crate::common::CivilDate { year, month, day }) + } + + fn daf_yomi_bavli_impl(year: i32, month: u8, day: u8) -> Option { + let jiff = jiff_from_parts(year, month, day)?; + let daf = jiff.limud(DafYomiBavli::default())?; + Some(DafResult { + tractate: to_ffi_tractate(tractate_to_code(daf.tractate)), + page: daf.page, + }) + } + + fn daf_yomi_yerushalmi_impl(year: i32, month: u8, day: u8) -> Option { + let jiff = jiff_from_parts(year, month, day)?; + let daf = jiff.limud(DafYomiYerushalmiVilna::default())?; + Some(DafResult { + tractate: to_ffi_tractate(tractate_to_code(daf.tractate)), + page: daf.page, + }) + } + + fn daf_hashavua_bavli_impl(year: i32, month: u8, day: u8) -> Option { + let jiff = jiff_from_parts(year, month, day)?; + let daf = jiff.limud(DafHashavuaBavli::default())?; + Some(DafResult { + tractate: to_ffi_tractate(tractate_to_code(daf.tractate)), + page: daf.page, + }) + } + + fn amud_yomi_bavli_dirshu_impl(year: i32, month: u8, day: u8) -> Option { + let jiff = jiff_from_parts(year, month, day)?; + let amud = jiff.limud(AmudYomiBavliDirshu::default())?; + Some(AmudResult { + tractate: to_ffi_tractate(tractate_to_code(amud.tractate)), + page: amud.page, + side: to_ffi_side(side_to_code(amud.side)), + }) + } + + fn mishna_yomis_impl(year: i32, month: u8, day: u8) -> Option { + let jiff = jiff_from_parts(year, month, day)?; + let mishnas = jiff.limud(MishnaYomis)?; + Some(MishnasResult { + start: to_mishna_result(mishnas.0), + end: to_mishna_result(mishnas.1), + }) + } + + fn pirkei_avos_impl(year: i32, month: u8, day: u8, in_israel: bool) -> Option { + let jiff = jiff_from_parts(year, month, day)?; + let unit = jiff.limud(PirkeiAvos { in_israel })?; + Some(match unit { + PirkeiAvosUnit::Single(perek) => PirkeiAvosResult { + kind: 0, + perek1: perek, + perek2: 0, + }, + PirkeiAvosUnit::Combined(p1, p2) => PirkeiAvosResult { + kind: 1, + perek1: p1, + perek2: p2, + }, + }) + } + + fn tehillim_monthly_impl(year: i32, month: u8, day: u8) -> Option { + let jiff = jiff_from_parts(year, month, day)?; + let unit = jiff.limud(TehillimMonthly)?; + Some(match unit { + TehillimUnit::Psalms { start, end } => TehillimResult { + kind: 0, + start, + end, + psalm: 0, + start_verse: 0, + end_verse: 0, + }, + TehillimUnit::PsalmVerses { + psalm, + start_verse, + end_verse, + } => TehillimResult { + kind: 1, + start: 0, + end: 0, + psalm, + start_verse, + end_verse, + }, + }) + } + + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn daf_yomi_bavli(year: i32, month: u8, day: u8) -> Option { + daf_yomi_bavli_impl(year, month, day) + } + + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn daf_yomi_yerushalmi(year: i32, month: u8, day: u8) -> Option { + daf_yomi_yerushalmi_impl(year, month, day) + } + + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn daf_hashavua_bavli(year: i32, month: u8, day: u8) -> Option { + daf_hashavua_bavli_impl(year, month, day) + } + + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn amud_yomi_bavli_dirshu(year: i32, month: u8, day: u8) -> Option { + amud_yomi_bavli_dirshu_impl(year, month, day) + } + + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn mishna_yomis(year: i32, month: u8, day: u8) -> Option { + mishna_yomis_impl(year, month, day) + } + + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn pirkei_avos(year: i32, month: u8, day: u8, in_israel: bool) -> Option { + pirkei_avos_impl(year, month, day, in_israel) + } + + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn tehillim_monthly(year: i32, month: u8, day: u8) -> Option { + tehillim_monthly_impl(year, month, day) + } + + /// Dart entry point: construct once and call instance methods. + #[diplomat::cfg(not(supports = free_functions))] + #[diplomat::opaque] + #[allow(dead_code)] + pub struct Limudim(u8); + + impl Limudim { + #[diplomat::attr(*, constructor)] + pub fn new() -> Box { + Box::new(Limudim(0)) + } + + pub fn daf_yomi_bavli(&self, year: i32, month: u8, day: u8) -> Option { + daf_yomi_bavli_impl(year, month, day) + } + + pub fn daf_yomi_yerushalmi(&self, year: i32, month: u8, day: u8) -> Option { + daf_yomi_yerushalmi_impl(year, month, day) + } + + pub fn daf_hashavua_bavli(&self, year: i32, month: u8, day: u8) -> Option { + daf_hashavua_bavli_impl(year, month, day) + } + + pub fn amud_yomi_bavli_dirshu(&self, year: i32, month: u8, day: u8) -> Option { + amud_yomi_bavli_dirshu_impl(year, month, day) + } + + pub fn mishna_yomis(&self, year: i32, month: u8, day: u8) -> Option { + mishna_yomis_impl(year, month, day) + } + + pub fn pirkei_avos(&self, year: i32, month: u8, day: u8, in_israel: bool) -> Option { + pirkei_avos_impl(year, month, day, in_israel) + } + + pub fn tehillim_monthly(&self, year: i32, month: u8, day: u8) -> Option { + tehillim_monthly_impl(year, month, day) + } + } +} diff --git a/interop/src/zman_preset.rs b/interop/src/zman_preset.rs new file mode 100644 index 0000000..d578bfe --- /dev/null +++ b/interop/src/zman_preset.rs @@ -0,0 +1,303 @@ +//! Generated zman preset diplomat bridge. +#![allow(missing_docs, dead_code)] + +#[diplomat::bridge] +mod ffi { + use core::fmt::Write; + + use diplomat_runtime::DiplomatWrite; + + use crate::generated::preset_dispatch::{PRESET_METADATA, ZMAN_PRESET_COUNT}; + + /// Stable identifier for a generated zman preset. + pub enum ZmanPresetId { + Alos120Minutes, + Alos120Zmanis, + Alos16Point1Degrees, + Alos18Degrees, + Alos19Degrees, + Alos19Point8Degrees, + Alos26Degrees, + Alos60Minutes, + Alos72Minutes, + Alos72Zmanis, + Alos90Minutes, + Alos90Zmanis, + Alos96Minutes, + Alos96Zmanis, + AlosBaalHatanya, + BainHashmashosRt13Point24Degrees, + BainHashmashosRt13Point5MinutesBefore7Point083Degrees, + BainHashmashosRt2Stars, + BainHashmashosRt58Point5Minutes, + BainHashmashosYereim13Point5Minutes, + BainHashmashosYereim16Point875Minutes, + BainHashmashosYereim18Minutes, + BainHashmashosYereim2Point1Degrees, + BainHashmashosYereim2Point8Degrees, + BainHashmashosYereim3Point05Degrees, + BeginAstronomicalTwilight, + BeginCivilTwilight, + BeginNauticalTwilight, + CandleLighting, + ChatzosHalayla, + ChatzosHayom, + ChatzosHayomAsHalfDay, + ElevationAdjustedSunrise, + ElevationAdjustedSunset, + EndAstronomicalTwilight, + EndCivilTwilight, + EndNauticalTwilight, + FixedLocalChatzosHayom, + MinchaGedola16Point1Degrees, + MinchaGedola30Minutes, + MinchaGedola72Minutes, + MinchaGedolaAhavatShalom, + MinchaGedolaAteretTorah, + MinchaGedolaBaalHatanya, + MinchaGedolaGra, + MinchaGedolaGrafixedLocalChatzos30Minutes, + MinchaGedolaGragreaterThan30, + MinchaKetana16Point1Degrees, + MinchaKetana72Minutes, + MinchaKetanaAhavatShalom, + MinchaKetanaAteretTorah, + MinchaKetanaBaalHatanya, + MinchaKetanaGra, + MinchaKetanaGrafixedLocalChatzosToSunset, + Misheyakir10Point2Degrees, + Misheyakir11Degrees, + Misheyakir11Point5Degrees, + Misheyakir12Point85Degrees, + Misheyakir7Point65Degrees, + Misheyakir9Point5Degrees, + PlagAhavatShalom, + PlagAlos16Point1DegreesToTzaisGeonim7Point083Degrees, + PlagAlosToSunset, + PlagHamincha120Minutes, + PlagHamincha120MinutesZmanis, + PlagHamincha16Point1Degrees, + PlagHamincha18Degrees, + PlagHamincha19Point8Degrees, + PlagHamincha26Degrees, + PlagHamincha60Minutes, + PlagHamincha72Minutes, + PlagHamincha72MinutesZmanis, + PlagHamincha90Minutes, + PlagHamincha90MinutesZmanis, + PlagHamincha96Minutes, + PlagHamincha96MinutesZmanis, + PlagHaminchaAteretTorah, + PlagHaminchaBaalHatanya, + PlagHaminchaGra, + PlagHaminchaGrafixedLocalChatzosToSunset, + PolarSunriseBenIshChai, + PolarSunsetBenIshChai, + SamuchLeMinchaKetana16Point1Degrees, + SamuchLeMinchaKetana72Minutes, + SamuchLeMinchaKetanaGra, + SeaLevelSunrise, + SeaLevelSunset, + SofZmanAchilasChametzBaalHatanya, + SofZmanAchilasChametzGra, + SofZmanAchilasChametzMga16Point1Degrees, + SofZmanAchilasChametzMga72Minutes, + SofZmanAchilasChametzMga72MinutesZmanis, + SofZmanBiurChametzBaalHatanya, + SofZmanBiurChametzGra, + SofZmanBiurChametzMga16Point1Degrees, + SofZmanBiurChametzMga72Minutes, + SofZmanBiurChametzMga72MinutesZmanis, + SofZmanKidushLevana15Days, + SofZmanKidushLevanaBetweenMoldos, + SofZmanShma3HoursBeforeChatzos, + SofZmanShmaAlos16Point1DegreesToTzaisGeonim7Point083Degrees, + SofZmanShmaAlos16Point1ToSunset, + SofZmanShmaAteretTorah, + SofZmanShmaBaalHatanya, + SofZmanShmaGra, + SofZmanShmaGrasunriseToFixedLocalChatzos, + SofZmanShmaMga120Minutes, + SofZmanShmaMga16Point1Degrees, + SofZmanShmaMga16Point1DegreesToFixedLocalChatzos, + SofZmanShmaMga18Degrees, + SofZmanShmaMga18DegreesToFixedLocalChatzos, + SofZmanShmaMga19Point8Degrees, + SofZmanShmaMga72Minutes, + SofZmanShmaMga72MinutesToFixedLocalChatzos, + SofZmanShmaMga72MinutesZmanis, + SofZmanShmaMga90Minutes, + SofZmanShmaMga90MinutesToFixedLocalChatzos, + SofZmanShmaMga90MinutesZmanis, + SofZmanShmaMga96Minutes, + SofZmanShmaMga96MinutesZmanis, + SofZmanTfila2HoursBeforeChatzos, + SofZmanTfilaAteretTorah, + SofZmanTfilaBaalHatanya, + SofZmanTfilaGra, + SofZmanTfilaGrasunriseToFixedLocalChatzos, + SofZmanTfilaMga120Minutes, + SofZmanTfilaMga16Point1Degrees, + SofZmanTfilaMga18Degrees, + SofZmanTfilaMga19Point8Degrees, + SofZmanTfilaMga72Minutes, + SofZmanTfilaMga72MinutesZmanis, + SofZmanTfilaMga90Minutes, + SofZmanTfilaMga90MinutesZmanis, + SofZmanTfilaMga96Minutes, + SofZmanTfilaMga96MinutesZmanis, + SolarMidnight, + SunTransit, + TchilasZmanKidushLevana3Days, + TchilasZmanKidushLevana7Days, + Tzais120Minutes, + Tzais120Zmanis, + Tzais16Point1Degrees, + Tzais18Degrees, + Tzais19Point8Degrees, + Tzais26Degrees, + Tzais50Minutes, + Tzais60Minutes, + Tzais72Minutes, + Tzais72Zmanis, + Tzais90Minutes, + Tzais90Zmanis, + Tzais96Minutes, + Tzais96Zmanis, + TzaisAteretTorah, + TzaisBaalHatanya, + TzaisGeonim3Point7Degrees, + TzaisGeonim3Point8Degrees, + TzaisGeonim4Point42Degrees, + TzaisGeonim4Point66Degrees, + TzaisGeonim4Point8Degrees, + TzaisGeonim5Point95Degrees, + TzaisGeonim6Point45Degrees, + TzaisGeonim7Point083Degrees, + TzaisGeonim7Point67Degrees, + TzaisGeonim8Point5Degrees, + TzaisGeonim9Point3Degrees, + TzaisGeonim9Point75Degrees, + } + + /// Broad category of a zman preset. + pub enum ZmanType { + Twilight, + Alos, + Misheyakir, + Netz, + SofZmanShma, + SofZmanTefila, + SofZmanAchilasChametz, + SofZmanBiurChametz, + ChatzosHayom, + MinchaGedola, + PlagHamincha, + SamuchLeMinchaKetana, + MinchaKetana, + BeinHashmashos, + CandleLighting, + Shkiya, + Tzais, + KidushLevana, + ChatzosHalayla, + } + + fn to_ffi_zman_type(zman_type: kosher_rust::zmanim::ZmanType) -> ZmanType { + match zman_type { + kosher_rust::zmanim::ZmanType::Twilight => ZmanType::Twilight, + kosher_rust::zmanim::ZmanType::Alos => ZmanType::Alos, + kosher_rust::zmanim::ZmanType::Misheyakir => ZmanType::Misheyakir, + kosher_rust::zmanim::ZmanType::Netz => ZmanType::Netz, + kosher_rust::zmanim::ZmanType::SofZmanShma => ZmanType::SofZmanShma, + kosher_rust::zmanim::ZmanType::SofZmanTefila => ZmanType::SofZmanTefila, + kosher_rust::zmanim::ZmanType::SofZmanAchilasChametz => ZmanType::SofZmanAchilasChametz, + kosher_rust::zmanim::ZmanType::SofZmanBiurChametz => ZmanType::SofZmanBiurChametz, + kosher_rust::zmanim::ZmanType::ChatzosHayom => ZmanType::ChatzosHayom, + kosher_rust::zmanim::ZmanType::MinchaGedola => ZmanType::MinchaGedola, + kosher_rust::zmanim::ZmanType::PlagHamincha => ZmanType::PlagHamincha, + kosher_rust::zmanim::ZmanType::SamuchLeMinchaKetana => ZmanType::SamuchLeMinchaKetana, + kosher_rust::zmanim::ZmanType::MinchaKetana => ZmanType::MinchaKetana, + kosher_rust::zmanim::ZmanType::BeinHashmashos => ZmanType::BeinHashmashos, + kosher_rust::zmanim::ZmanType::CandleLighting => ZmanType::CandleLighting, + kosher_rust::zmanim::ZmanType::Shkiya => ZmanType::Shkiya, + kosher_rust::zmanim::ZmanType::Tzais => ZmanType::Tzais, + kosher_rust::zmanim::ZmanType::KidushLevana => ZmanType::KidushLevana, + kosher_rust::zmanim::ZmanType::ChatzosHalayla => ZmanType::ChatzosHalayla, + } + } + + /// Returns the number of available presets. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn preset_count() -> u32 { + u32::try_from(ZMAN_PRESET_COUNT).unwrap_or(u32::MAX) + } + + /// Writes the display name for a preset. Returns false when the preset is unknown. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn preset_name(preset: ZmanPresetId, write: &mut DiplomatWrite) -> bool { + PRESET_METADATA + .get(preset as usize) + .map(|meta| write!(write, "{}", meta.name).is_ok()) + .unwrap_or(false) + } + + /// Returns whether a preset is deprecated. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn preset_deprecated(preset: ZmanPresetId) -> bool { + PRESET_METADATA.get(preset as usize).is_some_and(|meta| meta.deprecated) + } + + /// Writes the KosherJava-style method name for a preset. Returns false when unknown. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn preset_method_name(preset: ZmanPresetId, write: &mut DiplomatWrite) -> bool { + PRESET_METADATA + .get(preset as usize) + .map(|meta| write!(write, "{}", meta.method_name).is_ok()) + .unwrap_or(false) + } + + /// Returns the broad category for a preset. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn preset_zman_type(preset: ZmanPresetId) -> ZmanType { + to_ffi_zman_type(PRESET_METADATA[preset as usize].zman_type) + } + + /// Dart entry point: construct once and call instance methods. + #[diplomat::cfg(not(supports = free_functions))] + #[diplomat::opaque] + pub struct ZmanPresets(u8); + + impl ZmanPresets { + #[diplomat::attr(*, constructor)] + pub fn new() -> Box { + Box::new(ZmanPresets(0)) + } + + pub fn preset_count(&self) -> u32 { + u32::try_from(ZMAN_PRESET_COUNT).unwrap_or(u32::MAX) + } + + pub fn preset_name(&self, preset: ZmanPresetId, write: &mut DiplomatWrite) -> bool { + PRESET_METADATA + .get(preset as usize) + .map(|meta| write!(write, "{}", meta.name).is_ok()) + .unwrap_or(false) + } + + pub fn preset_deprecated(&self, preset: ZmanPresetId) -> bool { + PRESET_METADATA.get(preset as usize).is_some_and(|meta| meta.deprecated) + } + + pub fn preset_method_name(&self, preset: ZmanPresetId, write: &mut DiplomatWrite) -> bool { + PRESET_METADATA + .get(preset as usize) + .map(|meta| write!(write, "{}", meta.method_name).is_ok()) + .unwrap_or(false) + } + + pub fn preset_zman_type(&self, preset: ZmanPresetId) -> ZmanType { + to_ffi_zman_type(PRESET_METADATA[preset as usize].zman_type) + } + } +} diff --git a/interop/src/zmanim.rs b/interop/src/zmanim.rs new file mode 100644 index 0000000..d21fd47 --- /dev/null +++ b/interop/src/zmanim.rs @@ -0,0 +1,121 @@ +//! Zmanim FFI bridge. + +#[diplomat::bridge] +mod ffi { + use diplomat_runtime::DiplomatStr; + use jiff::{SignedDuration, civil::Date}; + use kosher_rust::zmanim::{ + ZmanimCalculator, + types::{config::CalculatorConfig as CoreCalculatorConfig, error::ZmanimError, location::Location}, + }; + + use crate::common::{parse_timezone, timestamp_to_epoch_ms}; + use crate::generated::preset_dispatch::preset_by_index; + + pub enum ZmanimErrorCode { + InvalidLatitude, + InvalidLongitude, + InvalidElevation, + TimeZoneRequired, + CalculationError, + AllDay, + AllNight, + TimeConversionError, + InvalidForDate, + InvalidHours, + } + + /// Calculator configuration (durations in minutes). + #[derive(Copy, Clone)] + pub struct CalculatorConfig { + pub candle_lighting_offset_minutes: i32, + pub use_astronomical_chatzos_for_other_zmanim: bool, + pub use_elevation: bool, + pub ateret_torah_sunset_offset_minutes: i32, + pub use_astronomical_chatzos: bool, + } + + #[diplomat::opaque] + pub struct FfiLocation(Location); + + impl FfiLocation { + /// Creates a location. Pass an empty timezone string when unknown. + pub fn new( + latitude: f64, + longitude: f64, + elevation: f64, + timezone_iana: &DiplomatStr, + ) -> Result, ZmanimErrorCode> { + let timezone = core::str::from_utf8(timezone_iana).ok().and_then(parse_timezone); + let location = Location::new(latitude, longitude, elevation, timezone).map_err(ZmanimErrorCode::from)?; + Ok(Box::new(FfiLocation(location))) + } + } + + #[diplomat::opaque] + pub struct FfiZmanimCalculator(ZmanimCalculator); + + impl FfiZmanimCalculator { + pub fn new( + location: &FfiLocation, + year: i32, + month: u8, + day: u8, + config: CalculatorConfig, + ) -> Option> { + let date = Date::new( + i16::try_from(year).ok()?, + i8::try_from(month).ok()?, + i8::try_from(day).ok()?, + ) + .ok()?; + let config = CoreCalculatorConfig { + candle_lighting_offset: SignedDuration::from_mins(i64::from(config.candle_lighting_offset_minutes)), + use_astronomical_chatzos_for_other_zmanim: config.use_astronomical_chatzos_for_other_zmanim, + use_elevation: config.use_elevation, + ateret_torah_sunset_offset: SignedDuration::from_mins(i64::from( + config.ateret_torah_sunset_offset_minutes, + )), + use_astronomical_chatzos: config.use_astronomical_chatzos, + }; + Some(Box::new(FfiZmanimCalculator(ZmanimCalculator::new( + location.0.clone(), + date, + config, + )))) + } + + /// Calculates a zman preset by index, returning UTC epoch milliseconds. + /// + /// The index matches [`ZmanPresetId`] in the generated [`crate::zman_preset`] module. + pub fn calculate_zman_by_index(&self, preset_index: u32) -> Result { + let preset_ref = preset_by_index(preset_index as usize).ok_or(ZmanimErrorCode::InvalidForDate)?; + let timestamp = self.0.calculate(preset_ref).map_err(ZmanimErrorCode::from)?; + Ok(timestamp_to_epoch_ms(timestamp)) + } + } + + impl From for ZmanimErrorCode { + fn from(value: crate::common::ZmanimErrorCode) -> Self { + use crate::common::ZmanimErrorCode as C; + match value { + C::InvalidLatitude => Self::InvalidLatitude, + C::InvalidLongitude => Self::InvalidLongitude, + C::InvalidElevation => Self::InvalidElevation, + C::TimeZoneRequired => Self::TimeZoneRequired, + C::CalculationError => Self::CalculationError, + C::AllDay => Self::AllDay, + C::AllNight => Self::AllNight, + C::TimeConversionError => Self::TimeConversionError, + C::InvalidForDate => Self::InvalidForDate, + C::InvalidHours => Self::InvalidHours, + } + } + } + + impl From for ZmanimErrorCode { + fn from(error: ZmanimError) -> Self { + Self::from(crate::common::ZmanimErrorCode::from(error)) + } + } +} diff --git a/interop/tests/adapter_tests.rs b/interop/tests/adapter_tests.rs new file mode 100644 index 0000000..a2f34d7 --- /dev/null +++ b/interop/tests/adapter_tests.rs @@ -0,0 +1,85 @@ +//! Adapter tests for the diplomat bridge (Rust-side, no generated bindings required). + +use interop::common::{civil_date_to_jiff, gregorian_to_hebrew, hebrew_to_gregorian, tractate_to_code}; +use kosher_rust::{calendar::HebrewHolidayCalendar, limudim::prelude::*, zmanim::prelude::*}; + +#[test] +#[allow(clippy::unwrap_used, clippy::expect_used)] +fn gregorian_hebrew_round_trip() { + let civil = interop::common::CivilDate { + year: 2024, + month: 1, + day: 20, + }; + let hebrew = gregorian_to_hebrew(civil).expect("valid conversion"); + assert_eq!(hebrew.year, 5784); + assert_eq!(hebrew.month, 5); + assert_eq!(hebrew.day, 10); + + let back = hebrew_to_gregorian(hebrew).expect("valid conversion"); + assert_eq!(back, civil); +} + +#[test] +#[allow(clippy::unwrap_used, clippy::expect_used)] +fn yom_kippur_is_assur_bemelacha() { + let date = interop::common::CivilDate { + year: 2025, + month: 10, + day: 2, + }; + let jiff = civil_date_to_jiff(date).expect("valid date"); + assert!(jiff.is_assur_bemelacha(false)); +} + +#[test] +#[allow(clippy::unwrap_used, clippy::expect_used)] +fn daf_yomi_bavli_matches_core_api() { + let date = interop::common::CivilDate { + year: 2017, + month: 12, + day: 28, + }; + let jiff = civil_date_to_jiff(date).expect("valid date"); + let daf = jiff.limud(DafYomiBavli::default()).expect("daf scheduled"); + assert_eq!(daf.tractate, Tractate::Shevuos); + assert_eq!(daf.page, 30); + assert!(matches!( + tractate_to_code(daf.tractate), + interop::common::TractateCode::Shevuos + )); +} + +#[test] +#[allow(clippy::unwrap_used, clippy::expect_used)] +fn elevation_adjusted_sunrise_via_preset_dispatch() { + use interop::generated::preset_dispatch::{PRESET_METADATA, preset_by_index}; + use jiff::{civil::Date, tz::TimeZone}; + + let location = + Location::new(31.78, 35.22, 0.0, Some(TimeZone::get("Asia/Jerusalem").unwrap())).expect("valid location"); + let calc = ZmanimCalculator::new(location, Date::new(2017, 10, 17).unwrap(), CalculatorConfig::default()); + let direct = calc + .calculate(&presets::ELEVATION_ADJUSTED_SUNRISE) + .expect("sunrise available"); + + let index = PRESET_METADATA + .iter() + .position(|meta| meta.method_name == "getSunrise") + .expect("sunrise preset in dispatch table"); + let via_dispatch = calc + .calculate(preset_by_index(index).expect("preset lookup")) + .expect("sunrise via dispatch"); + assert_eq!(direct, via_dispatch); +} + +#[test] +#[allow(clippy::unwrap_used, clippy::expect_used)] +fn preset_dispatch_count_matches_dsl() { + use interop::generated::preset_dispatch::{ZMAN_PRESET_COUNT, preset_by_index}; + + assert_eq!(ZMAN_PRESET_COUNT, 167); + assert!(preset_by_index(0).is_some()); + assert!(preset_by_index(ZMAN_PRESET_COUNT - 1).is_some()); + assert!(preset_by_index(ZMAN_PRESET_COUNT).is_none()); +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 0e152a8..ae95355 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,26 @@ [toolchain] channel = "1.93.0" components = ["rustfmt", "clippy"] +targets = [ + # Android + "armv7-linux-androideabi", + "aarch64-linux-android", + "x86_64-linux-android", + + # iOS (device + simulator) + "aarch64-apple-ios", + "aarch64-apple-ios-sim", + "x86_64-apple-ios", + + # Windows + "aarch64-pc-windows-msvc", + "x86_64-pc-windows-msvc", + + # Linux + "aarch64-unknown-linux-gnu", + "x86_64-unknown-linux-gnu", + + # macOS + "aarch64-apple-darwin", + "x86_64-apple-darwin", +] diff --git a/src/zmanim/mod.rs b/src/zmanim/mod.rs index 2355280..20f7293 100644 --- a/src/zmanim/mod.rs +++ b/src/zmanim/mod.rs @@ -15,7 +15,7 @@ //! //! Most callers use the ready-made constants in [`presets`] (for example //! [`presets::ELEVATION_ADJUSTED_SUNRISE`]). Each preset is a [`ZmanPreset`] backed -//! by a low-level [`ZmanPrimitive`] expression. +//! by a low-level [`ZmanPrimitive`] expression and tagged with a [`ZmanType`]. //! //! Failures return [`ZmanimError`] — unlike calendar or limud lookups, which use //! `Option` when a value simply does not apply on a given date. Some zmanim cannot @@ -88,7 +88,7 @@ pub mod prelude { pub use super::types::config::CalculatorConfig; pub use super::types::error::ZmanimError; pub use super::types::location::Location; - pub use super::{ZmanLike, ZmanPreset, ZmanimCalculator}; + pub use super::{ZmanLike, ZmanPreset, ZmanType, ZmanimCalculator}; } #[cfg(test)] @@ -146,6 +146,53 @@ pub trait ZmanLike { /// Custom zman definitions should put their calculation logic here. fn calculate(&self, calculator: &ZmanimCalculator) -> Result; } +/// Broad category of a zman preset (alos, tzais, sof zman shma, …). +/// +/// Every generated [`ZmanPreset`] carries one of these values so callers can +/// group or filter presets by kind without parsing method names. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +pub enum ZmanType { + /// Start and end of astronomical, civil, and nautical twilight. + Twilight, + /// Dawn (*alos*). + Alos, + /// Earliest time for tallis and tefillin (*misheyakir*). + Misheyakir, + /// Sunrise (*netz*). + Netz, + /// Latest time for the morning Shema (*sof zman shma*). + SofZmanShma, + /// Latest time for morning prayer (*sof zman tefila*). + SofZmanTefila, + /// Latest time to eat chametz on Erev Pesach. + SofZmanAchilasChametz, + /// Latest time to burn chametz on Erev Pesach. + SofZmanBiurChametz, + /// Midday (*chatzos hayom*). + ChatzosHayom, + /// Earliest Mincha (*mincha gedola*). + MinchaGedola, + /// Plag hamincha. + PlagHamincha, + /// Immediately before *mincha ketana* (*samuch le-mincha ketana*). + SamuchLeMinchaKetana, + /// Preferred Mincha time (*mincha ketana*). + MinchaKetana, + /// Twilight between sunset and nightfall (*bein hashmashos*). + BeinHashmashos, + /// Candle lighting before Shabbat or Yom Tov. + CandleLighting, + /// Sunset (*shkiya*). + Shkiya, + /// Nightfall (*tzais*). + Tzais, + /// Kiddush Levana window bounds. + KidushLevana, + /// Midnight (*chatzos halayla*). + ChatzosHalayla, +} + /// A named zman preset backed by a low-level [`ZmanPrimitive`]. /// /// Most callers should use presets directly instead of constructing @@ -154,6 +201,8 @@ pub trait ZmanLike { pub struct ZmanPreset { /// The primitive calculation used by this preset. pub event: ZmanPrimitive, + /// The broad category this preset belongs to. + pub zman_type: ZmanType, /// The KosherJava getter name (for example `getSunrise`). pub method_name: &'static str, /// The user-facing preset name. @@ -232,6 +281,12 @@ impl defmt::Format for ZmanimCalculator { #[cfg(feature = "defmt")] impl defmt::Format for ZmanPreset { fn format(&self, fmt: defmt::Formatter) { - defmt::write!(fmt, "ZmanPreset {{ event: {}, name: {} }}", self.event, self.name) + defmt::write!( + fmt, + "ZmanPreset {{ event: {}, zman_type: {}, name: {} }}", + self.event, + self.zman_type, + self.name + ) } } diff --git a/src/zmanim/presets.rs b/src/zmanim/presets.rs index d19b41c..afc8279 100644 --- a/src/zmanim/presets.rs +++ b/src/zmanim/presets.rs @@ -7,8 +7,8 @@ use alloc::format; #[cfg(feature = "alloc")] use alloc::string::{String, ToString}; -use crate::zmanim::ZmanPreset; use crate::zmanim::primitives::ZmanPrimitive; +use crate::zmanim::{ZmanPreset, ZmanType}; use jiff::SignedDuration as Duration; #[cfg(feature = "alloc")] @@ -28,6 +28,7 @@ fn format_minutes(duration: Duration) -> String { /// In places where sunrise cannot be calculated, this zman may not be available. pub static ALOS_120_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunrise, Duration::from_mins(-120)), + zman_type: ZmanType::Alos, method_name: "getAlos120Minutes", name: "Alos (120 Minutes)", #[cfg(feature = "alloc")] @@ -48,6 +49,7 @@ pub static ALOS_120_MINUTES: ZmanPreset = ZmanPreset { /// In places where sunrise or sunset cannot be calculated, this zman may not be available. pub static ALOS_120_ZMANIS: ZmanPreset = ZmanPreset { event: ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunrise, -2.0), + zman_type: ZmanType::Alos, method_name: "getAlos120Zmanis", name: "Alos (120 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -66,6 +68,7 @@ pub static ALOS_120_ZMANIS: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available if the sun does not reach low enough below the horizon. pub static ALOS_16_POINT_1_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunriseOffsetByDegrees(16.1), + zman_type: ZmanType::Alos, method_name: "getAlos16Point1Degrees", name: "Alos (16.1 Degrees)", #[cfg(feature = "alloc")] @@ -82,6 +85,7 @@ pub static ALOS_16_POINT_1_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available if the sun does not reach low enough below the horizon. pub static ALOS_18_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunriseOffsetByDegrees(18.0), + zman_type: ZmanType::Alos, method_name: "getAlos18Degrees", name: "Alos (18 Degrees)", #[cfg(feature = "alloc")] @@ -98,6 +102,7 @@ pub static ALOS_18_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available if the sun does not reach low enough below the horizon. pub static ALOS_19_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunriseOffsetByDegrees(19.0), + zman_type: ZmanType::Alos, method_name: "getAlos19Degrees", name: "Alos (19 Degrees)", #[cfg(feature = "alloc")] @@ -116,6 +121,7 @@ pub static ALOS_19_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available if the sun does not reach low enough below the horizon. pub static ALOS_19_POINT_8_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunriseOffsetByDegrees(19.8), + zman_type: ZmanType::Alos, method_name: "getAlos19Point8Degrees", name: "Alos (19.8 Degrees)", #[cfg(feature = "alloc")] @@ -136,6 +142,7 @@ pub static ALOS_19_POINT_8_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available if the sun does not reach low enough below the horizon. pub static ALOS_26_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunriseOffsetByDegrees(26.0), + zman_type: ZmanType::Alos, method_name: "getAlos26Degrees", name: "Alos (26 Degrees)", #[cfg(feature = "alloc")] @@ -154,6 +161,7 @@ pub static ALOS_26_DEGREES: ZmanPreset = ZmanPreset { /// In places where sunrise cannot be calculated, this zman may not be available. pub static ALOS_60_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunrise, Duration::from_mins(-60)), + zman_type: ZmanType::Alos, method_name: "getAlos60Minutes", name: "Alos (60 Minutes)", #[cfg(feature = "alloc")] @@ -172,6 +180,7 @@ pub static ALOS_60_MINUTES: ZmanPreset = ZmanPreset { /// In places where sunrise cannot be calculated, this zman may not be available. pub static ALOS_72_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunrise, Duration::from_mins(-72)), + zman_type: ZmanType::Alos, method_name: "getAlos72Minutes", name: "Alos (72 Minutes)", #[cfg(feature = "alloc")] @@ -190,6 +199,7 @@ pub static ALOS_72_MINUTES: ZmanPreset = ZmanPreset { /// In places where sunrise or sunset cannot be calculated, this zman may not be available. pub static ALOS_72_ZMANIS: ZmanPreset = ZmanPreset { event: ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunrise, -1.2), + zman_type: ZmanType::Alos, method_name: "getAlos72Zmanis", name: "Alos (72 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -208,6 +218,7 @@ pub static ALOS_72_ZMANIS: ZmanPreset = ZmanPreset { /// In places where sunrise cannot be calculated, this zman may not be available. pub static ALOS_90_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunrise, Duration::from_mins(-90)), + zman_type: ZmanType::Alos, method_name: "getAlos90Minutes", name: "Alos (90 Minutes)", #[cfg(feature = "alloc")] @@ -226,6 +237,7 @@ pub static ALOS_90_MINUTES: ZmanPreset = ZmanPreset { /// In places where sunrise or sunset cannot be calculated, this zman may not be available. pub static ALOS_90_ZMANIS: ZmanPreset = ZmanPreset { event: ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunrise, -1.5), + zman_type: ZmanType::Alos, method_name: "getAlos90Zmanis", name: "Alos (90 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -244,6 +256,7 @@ pub static ALOS_90_ZMANIS: ZmanPreset = ZmanPreset { /// In places where sunrise cannot be calculated, this zman may not be available. pub static ALOS_96_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunrise, Duration::from_mins(-96)), + zman_type: ZmanType::Alos, method_name: "getAlos96Minutes", name: "Alos (96 Minutes)", #[cfg(feature = "alloc")] @@ -262,6 +275,7 @@ pub static ALOS_96_MINUTES: ZmanPreset = ZmanPreset { /// In places where sunrise or sunset cannot be calculated, this zman may not be available. pub static ALOS_96_ZMANIS: ZmanPreset = ZmanPreset { event: ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunrise, -1.6), + zman_type: ZmanType::Alos, method_name: "getAlos96Zmanis", name: "Alos (96 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -280,6 +294,7 @@ pub static ALOS_96_ZMANIS: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available if the sun does not reach low enough below the horizon. pub static ALOS_BAAL_HATANYA: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunriseOffsetByDegrees(16.9), + zman_type: ZmanType::Alos, method_name: "getAlosBaalHatanya", name: "Alos (Baal Hatanya)", #[cfg(feature = "alloc")] @@ -296,6 +311,7 @@ pub static ALOS_BAAL_HATANYA: ZmanPreset = ZmanPreset { /// At some northern and southern locations, including places even south of the Arctic Circle and north of the Antarctic Circle, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static BAIN_HASHMASHOS_RT_13_POINT_24_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(13.24), + zman_type: ZmanType::BeinHashmashos, method_name: "getBainHashmashosRT13Point24Degrees", name: "Bain Hashmashos (Rabbeinu Tam, 13.24 Degrees)", #[cfg(feature = "alloc")] @@ -315,6 +331,7 @@ pub static BAIN_HASHMASHOS_RT_13_POINT_5_MINUTES_BEFORE_7_POINT_083_DEGREES: Zma &ZmanPrimitive::SunsetOffsetByDegrees(7.083333333333333), Duration::from_millis(-810000), ), + zman_type: ZmanType::BeinHashmashos, method_name: "getBainHashmashosRT13Point5MinutesBefore7Point083Degrees", name: "Bain Hashmashos (Rabbeinu Tam, 13.5 Minutes Before 7.083 Degrees)", #[cfg(feature = "alloc")] @@ -331,6 +348,7 @@ pub static BAIN_HASHMASHOS_RT_13_POINT_5_MINUTES_BEFORE_7_POINT_083_DEGREES: Zma /// At some northern and southern locations, including places even south of the Arctic Circle and north of the Antarctic Circle, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static BAIN_HASHMASHOS_RT_2_STARS: ZmanPreset = ZmanPreset { event: ZmanPrimitive::BainHashmashosRt2Stars, + zman_type: ZmanType::BeinHashmashos, method_name: "getBainHashmashosRT2Stars", name: "Bain Hashmashos (Rabbeinu Tam, 2 Stars)", #[cfg(feature = "alloc")] @@ -347,6 +365,7 @@ pub static BAIN_HASHMASHOS_RT_2_STARS: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static BAIN_HASHMASHOS_RT_58_POINT_5_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_millis(3510000)), + zman_type: ZmanType::BeinHashmashos, method_name: "getBainHashmashosRT58Point5Minutes", name: "Bain Hashmashos (Rabbeinu Tam, 58.5 Minutes)", #[cfg(feature = "alloc")] @@ -363,6 +382,7 @@ pub static BAIN_HASHMASHOS_RT_58_POINT_5_MINUTES: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static BAIN_HASHMASHOS_YEREIM_13_POINT_5_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_millis(-810000)), + zman_type: ZmanType::BeinHashmashos, method_name: "getBainHashmashosYereim13Point5Minutes", name: "Bain Hashmashos (Yereim, 13.5 Minutes)", #[cfg(feature = "alloc")] @@ -379,6 +399,7 @@ pub static BAIN_HASHMASHOS_YEREIM_13_POINT_5_MINUTES: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static BAIN_HASHMASHOS_YEREIM_16_POINT_875_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_millis(-1012500)), + zman_type: ZmanType::BeinHashmashos, method_name: "getBainHashmashosYereim16Point875Minutes", name: "Bain Hashmashos (Yereim, 16.875 Minutes)", #[cfg(feature = "alloc")] @@ -395,6 +416,7 @@ pub static BAIN_HASHMASHOS_YEREIM_16_POINT_875_MINUTES: ZmanPreset = ZmanPreset /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static BAIN_HASHMASHOS_YEREIM_18_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(-18)), + zman_type: ZmanType::BeinHashmashos, method_name: "getBainHashmashosYereim18Minutes", name: "Bain Hashmashos (Yereim, 18 Minutes)", #[cfg(feature = "alloc")] @@ -411,6 +433,7 @@ pub static BAIN_HASHMASHOS_YEREIM_18_MINUTES: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static BAIN_HASHMASHOS_YEREIM_2_POINT_1_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(-2.1), + zman_type: ZmanType::BeinHashmashos, method_name: "getBainHashmashosYereim2Point1Degrees", name: "Bain Hashmashos (Yereim, 2.1 Degrees)", #[cfg(feature = "alloc")] @@ -427,6 +450,7 @@ pub static BAIN_HASHMASHOS_YEREIM_2_POINT_1_DEGREES: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static BAIN_HASHMASHOS_YEREIM_2_POINT_8_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(-2.8), + zman_type: ZmanType::BeinHashmashos, method_name: "getBainHashmashosYereim2Point8Degrees", name: "Bain Hashmashos (Yereim, 2.8 Degrees)", #[cfg(feature = "alloc")] @@ -445,6 +469,7 @@ pub static BAIN_HASHMASHOS_YEREIM_2_POINT_8_DEGREES: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static BAIN_HASHMASHOS_YEREIM_3_POINT_05_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(-3.05), + zman_type: ZmanType::BeinHashmashos, method_name: "getBainHashmashosYereim3Point05Degrees", name: "Bain Hashmashos (Yereim, 3.05 Degrees)", #[cfg(feature = "alloc")] @@ -461,6 +486,7 @@ pub static BAIN_HASHMASHOS_YEREIM_3_POINT_05_DEGREES: ZmanPreset = ZmanPreset { /// This zman may not be available or cannot be calculated when the computation cannot be performed. pub static BEGIN_ASTRONOMICAL_TWILIGHT: ZmanPreset = ZmanPreset { event: ZmanPrimitive::BeginAstronomicalTwilight, + zman_type: ZmanType::Twilight, method_name: "getBeginAstronomicalTwilight", name: "Begin Astronomical Twilight", #[cfg(feature = "alloc")] @@ -477,6 +503,7 @@ pub static BEGIN_ASTRONOMICAL_TWILIGHT: ZmanPreset = ZmanPreset { /// This zman may not be available or cannot be calculated when the computation cannot be performed. pub static BEGIN_CIVIL_TWILIGHT: ZmanPreset = ZmanPreset { event: ZmanPrimitive::BeginCivilTwilight, + zman_type: ZmanType::Twilight, method_name: "getBeginCivilTwilight", name: "Begin Civil Twilight", #[cfg(feature = "alloc")] @@ -493,6 +520,7 @@ pub static BEGIN_CIVIL_TWILIGHT: ZmanPreset = ZmanPreset { /// This zman may not be available or cannot be calculated when the computation cannot be performed. pub static BEGIN_NAUTICAL_TWILIGHT: ZmanPreset = ZmanPreset { event: ZmanPrimitive::BeginNauticalTwilight, + zman_type: ZmanType::Twilight, method_name: "getBeginNauticalTwilight", name: "Begin Nautical Twilight", #[cfg(feature = "alloc")] @@ -509,6 +537,7 @@ pub static BEGIN_NAUTICAL_TWILIGHT: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static CANDLE_LIGHTING: ZmanPreset = ZmanPreset { event: ZmanPrimitive::CandleLighting, + zman_type: ZmanType::CandleLighting, method_name: "getCandleLighting", name: "Candle Lighting", #[cfg(feature = "alloc")] @@ -526,6 +555,7 @@ pub static CANDLE_LIGHTING: ZmanPreset = ZmanPreset { /// For how chatzos can be defined and calculated, see [The Definition of Chatzos](https://kosherjava.com/2020/07/02/definition-of-chatzos/) on the KosherJava blog. pub static CHATZOS_HALAYLA: ZmanPreset = ZmanPreset { event: ZmanPrimitive::ChatzosHalayla, + zman_type: ZmanType::ChatzosHalayla, method_name: "getChatzosHalayla", name: "Chatzos Halayla", #[cfg(feature = "alloc")] @@ -540,6 +570,7 @@ pub static CHATZOS_HALAYLA: ZmanPreset = ZmanPreset { /// For how chatzos can be defined and calculated, see [The Definition of Chatzos](https://kosherjava.com/2020/07/02/definition-of-chatzos/) on the KosherJava blog. pub static CHATZOS_HAYOM: ZmanPreset = ZmanPreset { event: ZmanPrimitive::ChatzosHayom, + zman_type: ZmanType::ChatzosHayom, method_name: "getChatzosHayom", name: "Chatzos Hayom", #[cfg(feature = "alloc")] @@ -560,6 +591,7 @@ pub static CHATZOS_HAYOM: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static CHATZOS_HAYOM_AS_HALF_DAY: ZmanPreset = ZmanPreset { event: ZmanPrimitive::ChatzosHayomAsHalfDay, + zman_type: ZmanType::ChatzosHayom, method_name: "getChatzosHayomAsHalfDay", name: "Chatzos Hayom (Midpoint of Sunrise and Sunset)", #[cfg(feature = "alloc")] @@ -576,6 +608,7 @@ pub static CHATZOS_HAYOM_AS_HALF_DAY: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static ELEVATION_ADJUSTED_SUNRISE: ZmanPreset = ZmanPreset { event: ZmanPrimitive::ElevationAdjustedSunrise, + zman_type: ZmanType::Netz, method_name: "getSunrise", name: "Sunrise", #[cfg(feature = "alloc")] @@ -592,6 +625,7 @@ pub static ELEVATION_ADJUSTED_SUNRISE: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static ELEVATION_ADJUSTED_SUNSET: ZmanPreset = ZmanPreset { event: ZmanPrimitive::ElevationAdjustedSunset, + zman_type: ZmanType::Shkiya, method_name: "getSunset", name: "Sunset", #[cfg(feature = "alloc")] @@ -608,6 +642,7 @@ pub static ELEVATION_ADJUSTED_SUNSET: ZmanPreset = ZmanPreset { /// This zman may not be available or cannot be calculated when the computation cannot be performed. pub static END_ASTRONOMICAL_TWILIGHT: ZmanPreset = ZmanPreset { event: ZmanPrimitive::EndAstronomicalTwilight, + zman_type: ZmanType::Twilight, method_name: "getEndAstronomicalTwilight", name: "End Astronomical Twilight", #[cfg(feature = "alloc")] @@ -624,6 +659,7 @@ pub static END_ASTRONOMICAL_TWILIGHT: ZmanPreset = ZmanPreset { /// This zman may not be available or cannot be calculated when the computation cannot be performed. pub static END_CIVIL_TWILIGHT: ZmanPreset = ZmanPreset { event: ZmanPrimitive::EndCivilTwilight, + zman_type: ZmanType::Twilight, method_name: "getEndCivilTwilight", name: "End Civil Twilight", #[cfg(feature = "alloc")] @@ -640,6 +676,7 @@ pub static END_CIVIL_TWILIGHT: ZmanPreset = ZmanPreset { /// This zman may not be available or cannot be calculated when the computation cannot be performed. pub static END_NAUTICAL_TWILIGHT: ZmanPreset = ZmanPreset { event: ZmanPrimitive::EndNauticalTwilight, + zman_type: ZmanType::Twilight, method_name: "getEndNauticalTwilight", name: "End Nautical Twilight", #[cfg(feature = "alloc")] @@ -656,6 +693,7 @@ pub static END_NAUTICAL_TWILIGHT: ZmanPreset = ZmanPreset { /// This is the time of chatzos according to the [Aruch Hashulchan](https://en.wikipedia.org/wiki/Aruch_HaShulchan) ([Orach Chaim 233:14](https://hebrewbooks.org/pdfpager.aspx?req=7705&pgnum=426)) and [Rabbi Moshe Feinstein](https://en.wikipedia.org/wiki/Moshe_Feinstein) ([Igros Moshe, Orach Chaim 1:24](https://hebrewbooks.org/pdfpager.aspx?req=916&st=&pgnum=67), [2:20](https://hebrewbooks.org/pdfpager.aspx?req=14675&pgnum=191)). pub static FIXED_LOCAL_CHATZOS_HAYOM: ZmanPreset = ZmanPreset { event: ZmanPrimitive::LocalMeanTime(12.0), + zman_type: ZmanType::ChatzosHayom, method_name: "getFixedLocalChatzosHayom", name: "Chatzos Hayom (Fixed Local Chatzos)", #[cfg(feature = "alloc")] @@ -676,6 +714,7 @@ pub static MINCHA_GEDOLA_16_POINT_1_DEGREES: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(16.1), true, ), + zman_type: ZmanType::MinchaGedola, method_name: "getMinchaGedola16Point1Degrees", name: "Mincha Gedola (16.1 Degrees)", #[cfg(feature = "alloc")] @@ -694,6 +733,7 @@ pub static MINCHA_GEDOLA_16_POINT_1_DEGREES: ZmanPreset = ZmanPreset { /// In places where chatzos cannot be calculated, this zman may not be available. pub static MINCHA_GEDOLA_30_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ChatzosHayom, Duration::from_mins(30)), + zman_type: ZmanType::MinchaGedola, method_name: "getMinchaGedola30Minutes", name: "Mincha Gedola (30 Minutes)", #[cfg(feature = "alloc")] @@ -714,6 +754,7 @@ pub static MINCHA_GEDOLA_72_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(72)), true, ), + zman_type: ZmanType::MinchaGedola, method_name: "getMinchaGedola72Minutes", name: "Mincha Gedola (72 Minutes)", #[cfg(feature = "alloc")] @@ -732,6 +773,7 @@ pub static MINCHA_GEDOLA_72_MINUTES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available if the sun does not reach low enough below the horizon. pub static MINCHA_GEDOLA_AHAVAT_SHALOM: ZmanPreset = ZmanPreset { event: ZmanPrimitive::MinchaGedolaAhavatShalom, + zman_type: ZmanType::MinchaGedola, method_name: "getMinchaGedolaAhavatShalom", name: "Mincha Gedola (Ahavat Shalom)", #[cfg(feature = "alloc")] @@ -754,6 +796,7 @@ pub static MINCHA_GEDOLA_ATERET_TORAH: ZmanPreset = ZmanPreset { &ZmanPrimitive::TzaisAteretTorah, false, ), + zman_type: ZmanType::MinchaGedola, method_name: "getMinchaGedolaAteretTorah", name: "Mincha Gedola (Ateret Torah)", #[cfg(feature = "alloc")] @@ -777,6 +820,7 @@ pub static MINCHA_GEDOLA_BAAL_HATANYA: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(1.583), true, ), + zman_type: ZmanType::MinchaGedola, method_name: "getMinchaGedolaBaalHatanya", name: "Mincha Gedola (Baal Hatanya)", #[cfg(feature = "alloc")] @@ -799,6 +843,7 @@ pub static MINCHA_GEDOLA_GRA: ZmanPreset = ZmanPreset { &ZmanPrimitive::ConfiguredSunset, true, ), + zman_type: ZmanType::MinchaGedola, method_name: "getMinchaGedolaGRA", name: "Mincha Gedola (GR'A)", #[cfg(feature = "alloc")] @@ -815,6 +860,7 @@ pub static MINCHA_GEDOLA_GRA: ZmanPreset = ZmanPreset { /// In places where fixed local chatzos cannot be calculated, this zman may not be available. pub static MINCHA_GEDOLA_GRAFIXED_LOCAL_CHATZOS_30_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::LocalMeanTime(12.0), Duration::from_mins(30)), + zman_type: ZmanType::MinchaGedola, method_name: "getMinchaGedolaGRAFixedLocalChatzos30Minutes", name: "Mincha Gedola (GR'A, Fixed Local Chatzos, 30 Minutes)", #[cfg(feature = "alloc")] @@ -831,6 +877,7 @@ pub static MINCHA_GEDOLA_GRAFIXED_LOCAL_CHATZOS_30_MINUTES: ZmanPreset = ZmanPre /// In places where sunrise, sunset, or chatzos cannot be calculated, this zman may not be available. pub static MINCHA_GEDOLA_GRAGREATER_THAN_30: ZmanPreset = ZmanPreset { event: ZmanPrimitive::MinchaGedolaGraGreaterThan30, + zman_type: ZmanType::MinchaGedola, method_name: "getMinchaGedolaGRAGreaterThan30", name: "Mincha Gedola (GR'A, Greater Than 30)", #[cfg(feature = "alloc")] @@ -851,6 +898,7 @@ pub static MINCHA_KETANA_16_POINT_1_DEGREES: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(16.1), true, ), + zman_type: ZmanType::MinchaKetana, method_name: "getMinchaKetana16Point1Degrees", name: "Mincha Ketana (16.1 Degrees)", #[cfg(feature = "alloc")] @@ -871,6 +919,7 @@ pub static MINCHA_KETANA_72_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(72)), true, ), + zman_type: ZmanType::MinchaKetana, method_name: "getMinchaKetana72Minutes", name: "Mincha Ketana (72 Minutes)", #[cfg(feature = "alloc")] @@ -887,6 +936,7 @@ pub static MINCHA_KETANA_72_MINUTES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available if the sun does not reach low enough below the horizon. pub static MINCHA_KETANA_AHAVAT_SHALOM: ZmanPreset = ZmanPreset { event: ZmanPrimitive::MinchaKetanaAhavatShalom, + zman_type: ZmanType::MinchaKetana, method_name: "getMinchaKetanaAhavatShalom", name: "Mincha Ketana (Ahavat Shalom)", #[cfg(feature = "alloc")] @@ -909,6 +959,7 @@ pub static MINCHA_KETANA_ATERET_TORAH: ZmanPreset = ZmanPreset { &ZmanPrimitive::TzaisAteretTorah, false, ), + zman_type: ZmanType::MinchaKetana, method_name: "getMinchaKetanaAteretTorah", name: "Mincha Ketana (Ateret Torah)", #[cfg(feature = "alloc")] @@ -932,6 +983,7 @@ pub static MINCHA_KETANA_BAAL_HATANYA: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(1.583), true, ), + zman_type: ZmanType::MinchaKetana, method_name: "getMinchaKetanaBaalHatanya", name: "Mincha Ketana (Baal Hatanya)", #[cfg(feature = "alloc")] @@ -954,6 +1006,7 @@ pub static MINCHA_KETANA_GRA: ZmanPreset = ZmanPreset { &ZmanPrimitive::ConfiguredSunset, true, ), + zman_type: ZmanType::MinchaKetana, method_name: "getMinchaKetanaGRA", name: "Mincha Ketana (GR'A)", #[cfg(feature = "alloc")] @@ -974,6 +1027,7 @@ pub static MINCHA_KETANA_GRAFIXED_LOCAL_CHATZOS_TO_SUNSET: ZmanPreset = ZmanPres &ZmanPrimitive::ConfiguredSunset, 3.5, ), + zman_type: ZmanType::MinchaKetana, method_name: "getMinchaKetanaGRAFixedLocalChatzosToSunset", name: "Mincha Ketana (GR'A, Fixed Local Chatzos to Sunset)", #[cfg(feature = "alloc")] @@ -992,6 +1046,7 @@ pub static MINCHA_KETANA_GRAFIXED_LOCAL_CHATZOS_TO_SUNSET: ZmanPreset = ZmanPres /// At some northern and southern locations, this zman may not be available if the sun does not reach low enough below the horizon. pub static MISHEYAKIR_10_POINT_2_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunriseOffsetByDegrees(10.2), + zman_type: ZmanType::Misheyakir, method_name: "getMisheyakir10Point2Degrees", name: "Misheyakir (10.2 Degrees)", #[cfg(feature = "alloc")] @@ -1010,6 +1065,7 @@ pub static MISHEYAKIR_10_POINT_2_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available if the sun does not reach low enough below the horizon. pub static MISHEYAKIR_11_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunriseOffsetByDegrees(11.0), + zman_type: ZmanType::Misheyakir, method_name: "getMisheyakir11Degrees", name: "Misheyakir (11 Degrees)", #[cfg(feature = "alloc")] @@ -1028,6 +1084,7 @@ pub static MISHEYAKIR_11_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available if the sun does not reach low enough below the horizon. pub static MISHEYAKIR_11_POINT_5_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunriseOffsetByDegrees(11.5), + zman_type: ZmanType::Misheyakir, method_name: "getMisheyakir11Point5Degrees", name: "Misheyakir (11.5 Degrees)", #[cfg(feature = "alloc")] @@ -1048,6 +1105,7 @@ pub static MISHEYAKIR_11_POINT_5_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available if the sun does not reach low enough below the horizon. pub static MISHEYAKIR_12_POINT_85_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunriseOffsetByDegrees(12.85), + zman_type: ZmanType::Misheyakir, method_name: "getMisheyakir12Point85Degrees", name: "Misheyakir (12.85 Degrees)", #[cfg(feature = "alloc")] @@ -1066,6 +1124,7 @@ pub static MISHEYAKIR_12_POINT_85_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available if the sun does not reach low enough below the horizon. pub static MISHEYAKIR_7_POINT_65_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunriseOffsetByDegrees(7.65), + zman_type: ZmanType::Misheyakir, method_name: "getMisheyakir7Point65Degrees", name: "Misheyakir (7.65 Degrees)", #[cfg(feature = "alloc")] @@ -1084,6 +1143,7 @@ pub static MISHEYAKIR_7_POINT_65_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available if the sun does not reach low enough below the horizon. pub static MISHEYAKIR_9_POINT_5_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunriseOffsetByDegrees(9.5), + zman_type: ZmanType::Misheyakir, method_name: "getMisheyakir9Point5Degrees", name: "Misheyakir (9.5 Degrees)", #[cfg(feature = "alloc")] @@ -1100,6 +1160,7 @@ pub static MISHEYAKIR_9_POINT_5_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available if the sun does not reach low enough below the horizon. pub static PLAG_AHAVAT_SHALOM: ZmanPreset = ZmanPreset { event: ZmanPrimitive::PlagAhavatShalom, + zman_type: ZmanType::PlagHamincha, method_name: "getPlagAhavatShalom", name: "Plag Hamincha (Ahavat Shalom)", #[cfg(feature = "alloc")] @@ -1120,6 +1181,7 @@ pub static PLAG_ALOS_16_POINT_1_DEGREES_TO_TZAIS_GEONIM_7_POINT_083_DEGREES: Zma &ZmanPrimitive::SunsetOffsetByDegrees(7.083333333333333), false, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagAlos16Point1DegreesToTzaisGeonim7Point083Degrees", name: "Plag Hamincha (Alos 16.1 to Tzais Geonim 7.083 Degrees)", #[cfg(feature = "alloc")] @@ -1142,6 +1204,7 @@ pub static PLAG_ALOS_TO_SUNSET: ZmanPreset = ZmanPreset { &ZmanPrimitive::ConfiguredSunset, false, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagAlosToSunset", name: "Plag Hamincha (Alos 16.1 to Sunset)", #[cfg(feature = "alloc")] @@ -1164,6 +1227,7 @@ pub static PLAG_HAMINCHA_120_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(120)), true, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHamincha120Minutes", name: "Plag Hamincha (120 Minutes)", #[cfg(feature = "alloc")] @@ -1186,6 +1250,7 @@ pub static PLAG_HAMINCHA_120_MINUTES_ZMANIS: ZmanPreset = ZmanPreset { &ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunset, 2.0), true, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHamincha120MinutesZmanis", name: "Plag Hamincha (120 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -1208,6 +1273,7 @@ pub static PLAG_HAMINCHA_16_POINT_1_DEGREES: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(16.1), true, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHamincha16Point1Degrees", name: "Plag Hamincha (16.1 Degrees)", #[cfg(feature = "alloc")] @@ -1230,6 +1296,7 @@ pub static PLAG_HAMINCHA_18_DEGREES: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(18.0), true, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHamincha18Degrees", name: "Plag Hamincha (18 Degrees)", #[cfg(feature = "alloc")] @@ -1252,6 +1319,7 @@ pub static PLAG_HAMINCHA_19_POINT_8_DEGREES: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(19.8), true, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHamincha19Point8Degrees", name: "Plag Hamincha (19.8 Degrees)", #[cfg(feature = "alloc")] @@ -1274,6 +1342,7 @@ pub static PLAG_HAMINCHA_26_DEGREES: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(26.0), true, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHamincha26Degrees", name: "Plag Hamincha (26 Degrees)", #[cfg(feature = "alloc")] @@ -1294,6 +1363,7 @@ pub static PLAG_HAMINCHA_60_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(60)), true, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHamincha60Minutes", name: "Plag Hamincha (60 Minutes)", #[cfg(feature = "alloc")] @@ -1316,6 +1386,7 @@ pub static PLAG_HAMINCHA_72_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(72)), true, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHamincha72Minutes", name: "Plag Hamincha (72 Minutes)", #[cfg(feature = "alloc")] @@ -1338,6 +1409,7 @@ pub static PLAG_HAMINCHA_72_MINUTES_ZMANIS: ZmanPreset = ZmanPreset { &ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunset, 1.2), true, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHamincha72MinutesZmanis", name: "Plag Hamincha (72 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -1360,6 +1432,7 @@ pub static PLAG_HAMINCHA_90_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(90)), true, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHamincha90Minutes", name: "Plag Hamincha (90 Minutes)", #[cfg(feature = "alloc")] @@ -1382,6 +1455,7 @@ pub static PLAG_HAMINCHA_90_MINUTES_ZMANIS: ZmanPreset = ZmanPreset { &ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunset, 1.5), true, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHamincha90MinutesZmanis", name: "Plag Hamincha (90 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -1404,6 +1478,7 @@ pub static PLAG_HAMINCHA_96_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(96)), true, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHamincha96Minutes", name: "Plag Hamincha (96 Minutes)", #[cfg(feature = "alloc")] @@ -1426,6 +1501,7 @@ pub static PLAG_HAMINCHA_96_MINUTES_ZMANIS: ZmanPreset = ZmanPreset { &ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunset, 1.6), true, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHamincha96MinutesZmanis", name: "Plag Hamincha (96 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -1448,6 +1524,7 @@ pub static PLAG_HAMINCHA_ATERET_TORAH: ZmanPreset = ZmanPreset { &ZmanPrimitive::TzaisAteretTorah, false, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHaminchaAteretTorah", name: "Plag Hamincha (Ateret Torah)", #[cfg(feature = "alloc")] @@ -1473,6 +1550,7 @@ pub static PLAG_HAMINCHA_BAAL_HATANYA: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(1.583), true, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHaminchaBaalHatanya", name: "Plag Hamincha (Baal Hatanya)", #[cfg(feature = "alloc")] @@ -1495,6 +1573,7 @@ pub static PLAG_HAMINCHA_GRA: ZmanPreset = ZmanPreset { &ZmanPrimitive::ConfiguredSunset, true, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHaminchaGRA", name: "Plag Hamincha (GR'A)", #[cfg(feature = "alloc")] @@ -1515,6 +1594,7 @@ pub static PLAG_HAMINCHA_GRAFIXED_LOCAL_CHATZOS_TO_SUNSET: ZmanPreset = ZmanPres &ZmanPrimitive::ConfiguredSunset, 4.75, ), + zman_type: ZmanType::PlagHamincha, method_name: "getPlagHaminchaGRAFixedLocalChatzosToSunset", name: "Plag Hamincha (GR'A, Fixed Local Chatzos to Sunset)", #[cfg(feature = "alloc")] @@ -1531,6 +1611,7 @@ pub static PLAG_HAMINCHA_GRAFIXED_LOCAL_CHATZOS_TO_SUNSET: ZmanPreset = ZmanPres /// If there is no sunrise that day and the sun does not reach azimuth 90 degrees, this zman may not be available or cannot be calculated. pub static POLAR_SUNRISE_BEN_ISH_CHAI: ZmanPreset = ZmanPreset { event: ZmanPrimitive::PolarSunriseBenIshChai, + zman_type: ZmanType::Netz, method_name: "getPolarSunriseBenIshChai", name: "Polar Sunrise Ben Ish Chai", #[cfg(feature = "alloc")] @@ -1547,6 +1628,7 @@ pub static POLAR_SUNRISE_BEN_ISH_CHAI: ZmanPreset = ZmanPreset { /// If there is no sunset that day and the sun does not reach azimuth 270 degrees, this zman may not be available or cannot be calculated. pub static POLAR_SUNSET_BEN_ISH_CHAI: ZmanPreset = ZmanPreset { event: ZmanPrimitive::PolarSunsetBenIshChai, + zman_type: ZmanType::Shkiya, method_name: "getPolarSunsetBenIshChai", name: "Polar Sunset Ben Ish Chai", #[cfg(feature = "alloc")] @@ -1571,6 +1653,7 @@ pub static SAMUCH_LE_MINCHA_KETANA_16_POINT_1_DEGREES: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(16.1), true, ), + zman_type: ZmanType::SamuchLeMinchaKetana, method_name: "getSamuchLeMinchaKetana16Point1Degrees", name: "Samuch Le Mincha Ketana (16.1 Degrees)", #[cfg(feature = "alloc")] @@ -1595,6 +1678,7 @@ pub static SAMUCH_LE_MINCHA_KETANA_72_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(72)), true, ), + zman_type: ZmanType::SamuchLeMinchaKetana, method_name: "getSamuchLeMinchaKetana72Minutes", name: "Samuch Le Mincha Ketana (72 Minutes)", #[cfg(feature = "alloc")] @@ -1619,6 +1703,7 @@ pub static SAMUCH_LE_MINCHA_KETANA_GRA: ZmanPreset = ZmanPreset { &ZmanPrimitive::ConfiguredSunset, true, ), + zman_type: ZmanType::SamuchLeMinchaKetana, method_name: "getSamuchLeMinchaKetanaGRA", name: "Samuch Le Mincha Ketana (GR'A)", #[cfg(feature = "alloc")] @@ -1635,6 +1720,7 @@ pub static SAMUCH_LE_MINCHA_KETANA_GRA: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static SEA_LEVEL_SUNRISE: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SeaLevelSunrise, + zman_type: ZmanType::Netz, method_name: "getSeaLevelSunrise", name: "Sea Level Sunrise", #[cfg(feature = "alloc")] @@ -1651,6 +1737,7 @@ pub static SEA_LEVEL_SUNRISE: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static SEA_LEVEL_SUNSET: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SeaLevelSunset, + zman_type: ZmanType::Shkiya, method_name: "getSeaLevelSunset", name: "Sea Level Sunset", #[cfg(feature = "alloc")] @@ -1669,6 +1756,7 @@ pub static SOF_ZMAN_ACHILAS_CHAMETZ_BAAL_HATANYA: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(1.583), true, ), + zman_type: ZmanType::SofZmanAchilasChametz, method_name: "getSofZmanAchilasChametzBaalHatanya", name: "Sof Zman Achilas Chametz (Baal Hatanya)", #[cfg(feature = "alloc")] @@ -1687,6 +1775,7 @@ pub static SOF_ZMAN_ACHILAS_CHAMETZ_GRA: ZmanPreset = ZmanPreset { &ZmanPrimitive::ConfiguredSunset, true, ), + zman_type: ZmanType::SofZmanAchilasChametz, method_name: "getSofZmanAchilasChametzGRA", name: "Sof Zman Achilas Chametz (GR'A)", #[cfg(feature = "alloc")] @@ -1705,6 +1794,7 @@ pub static SOF_ZMAN_ACHILAS_CHAMETZ_MGA_16_POINT_1_DEGREES: ZmanPreset = ZmanPre &ZmanPrimitive::SunsetOffsetByDegrees(16.1), true, ), + zman_type: ZmanType::SofZmanAchilasChametz, method_name: "getSofZmanAchilasChametzMGA16Point1Degrees", name: "Sof Zman Achilas Chametz (MGA, 16.1 Degrees)", #[cfg(feature = "alloc")] @@ -1723,6 +1813,7 @@ pub static SOF_ZMAN_ACHILAS_CHAMETZ_MGA_72_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(72)), true, ), + zman_type: ZmanType::SofZmanAchilasChametz, method_name: "getSofZmanAchilasChametzMGA72Minutes", name: "Sof Zman Achilas Chametz (MGA, 72 Minutes)", #[cfg(feature = "alloc")] @@ -1741,6 +1832,7 @@ pub static SOF_ZMAN_ACHILAS_CHAMETZ_MGA_72_MINUTES_ZMANIS: ZmanPreset = ZmanPres &ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunset, 1.2), true, ), + zman_type: ZmanType::SofZmanAchilasChametz, method_name: "getSofZmanAchilasChametzMGA72MinutesZmanis", name: "Sof Zman Achilas Chametz (MGA, 72 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -1759,6 +1851,7 @@ pub static SOF_ZMAN_BIUR_CHAMETZ_BAAL_HATANYA: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(1.583), true, ), + zman_type: ZmanType::SofZmanBiurChametz, method_name: "getSofZmanBiurChametzBaalHatanya", name: "Sof Zman Biur Chametz (Baal Hatanya)", #[cfg(feature = "alloc")] @@ -1777,6 +1870,7 @@ pub static SOF_ZMAN_BIUR_CHAMETZ_GRA: ZmanPreset = ZmanPreset { &ZmanPrimitive::ConfiguredSunset, true, ), + zman_type: ZmanType::SofZmanBiurChametz, method_name: "getSofZmanBiurChametzGRA", name: "Sof Zman Biur Chametz (GR'A)", #[cfg(feature = "alloc")] @@ -1795,6 +1889,7 @@ pub static SOF_ZMAN_BIUR_CHAMETZ_MGA_16_POINT_1_DEGREES: ZmanPreset = ZmanPreset &ZmanPrimitive::SunsetOffsetByDegrees(16.1), true, ), + zman_type: ZmanType::SofZmanBiurChametz, method_name: "getSofZmanBiurChametzMGA16Point1Degrees", name: "Sof Zman Biur Chametz (MGA, 16.1 Degrees)", #[cfg(feature = "alloc")] @@ -1813,6 +1908,7 @@ pub static SOF_ZMAN_BIUR_CHAMETZ_MGA_72_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(72)), true, ), + zman_type: ZmanType::SofZmanBiurChametz, method_name: "getSofZmanBiurChametzMGA72Minutes", name: "Sof Zman Biur Chametz (MGA, 72 Minutes)", #[cfg(feature = "alloc")] @@ -1831,6 +1927,7 @@ pub static SOF_ZMAN_BIUR_CHAMETZ_MGA_72_MINUTES_ZMANIS: ZmanPreset = ZmanPreset &ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunset, 1.2), true, ), + zman_type: ZmanType::SofZmanBiurChametz, method_name: "getSofZmanBiurChametzMGA72MinutesZmanis", name: "Sof Zman Biur Chametz (MGA, 72 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -1847,6 +1944,7 @@ pub static SOF_ZMAN_BIUR_CHAMETZ_MGA_72_MINUTES_ZMANIS: ZmanPreset = ZmanPreset /// Note that although this time may be during the daytime, Kiddush Levana cannot be said during the daytime. pub static SOF_ZMAN_KIDUSH_LEVANA_15_DAYS: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SofZmanKidushLevana15Days, + zman_type: ZmanType::KidushLevana, method_name: "getSofZmanKidushLevana15Days", name: "Sof Zman Kidush Levana (15 Days)", #[cfg(feature = "alloc")] @@ -1863,6 +1961,7 @@ pub static SOF_ZMAN_KIDUSH_LEVANA_15_DAYS: ZmanPreset = ZmanPreset { /// Note that although this time may be during the daytime, Kiddush Levana cannot be said during the daytime. pub static SOF_ZMAN_KIDUSH_LEVANA_BETWEEN_MOLDOS: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SofZmanKidushLevanaBetweenMoldos, + zman_type: ZmanType::KidushLevana, method_name: "getSofZmanKidushLevanaBetweenMoldos", name: "Sof Zman Kidush Levana (Between Moldos)", #[cfg(feature = "alloc")] @@ -1881,6 +1980,7 @@ pub static SOF_ZMAN_KIDUSH_LEVANA_BETWEEN_MOLDOS: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static SOF_ZMAN_SHMA_3_HOURS_BEFORE_CHATZOS: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ChatzosHayom, Duration::from_mins(-180)), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShma3HoursBeforeChatzos", name: "Sof Zman Shma (3 Hours Before Chatzos)", #[cfg(feature = "alloc")] @@ -1901,6 +2001,7 @@ pub static SOF_ZMAN_SHMA_ALOS_16_POINT_1_DEGREES_TO_TZAIS_GEONIM_7_POINT_083_DEG &ZmanPrimitive::SunsetOffsetByDegrees(7.083333333333333), false, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaAlos16Point1DegreesToTzaisGeonim7Point083Degrees", name: "Sof Zman Shma (Alos 16.1 to Tzais Geonim 7.083 Degrees)", #[cfg(feature = "alloc")] @@ -1921,6 +2022,7 @@ pub static SOF_ZMAN_SHMA_ALOS_16_POINT_1_TO_SUNSET: ZmanPreset = ZmanPreset { &ZmanPrimitive::ConfiguredSunset, false, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaAlos16Point1ToSunset", name: "Sof Zman Shma (Alos 16.1 to Sunset)", #[cfg(feature = "alloc")] @@ -1941,6 +2043,7 @@ pub static SOF_ZMAN_SHMA_ATERET_TORAH: ZmanPreset = ZmanPreset { &ZmanPrimitive::TzaisAteretTorah, false, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaAteretTorah", name: "Sof Zman Shma (Ateret Torah)", #[cfg(feature = "alloc")] @@ -1964,6 +2067,7 @@ pub static SOF_ZMAN_SHMA_BAAL_HATANYA: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(1.583), true, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaBaalHatanya", name: "Sof Zman Shma (Baal Hatanya)", #[cfg(feature = "alloc")] @@ -1984,6 +2088,7 @@ pub static SOF_ZMAN_SHMA_GRA: ZmanPreset = ZmanPreset { &ZmanPrimitive::ConfiguredSunset, true, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaGRA", name: "Sof Zman Shma (GR'A)", #[cfg(feature = "alloc")] @@ -2004,6 +2109,7 @@ pub static SOF_ZMAN_SHMA_GRASUNRISE_TO_FIXED_LOCAL_CHATZOS: ZmanPreset = ZmanPre &ZmanPrimitive::LocalMeanTime(12.0), 3.0, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaGRASunriseToFixedLocalChatzos", name: "Sof Zman Shma (GR'A, Sunrise to Fixed Local Chatzos)", #[cfg(feature = "alloc")] @@ -2024,6 +2130,7 @@ pub static SOF_ZMAN_SHMA_MGA_120_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(120)), true, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaMGA120Minutes", name: "Sof Zman Shma (MGA, 120 Minutes)", #[cfg(feature = "alloc")] @@ -2044,6 +2151,7 @@ pub static SOF_ZMAN_SHMA_MGA_16_POINT_1_DEGREES: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(16.1), true, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaMGA16Point1Degrees", name: "Sof Zman Shma (MGA, 16.1 Degrees)", #[cfg(feature = "alloc")] @@ -2064,6 +2172,7 @@ pub static SOF_ZMAN_SHMA_MGA_16_POINT_1_DEGREES_TO_FIXED_LOCAL_CHATZOS: ZmanPres &ZmanPrimitive::LocalMeanTime(12.0), 3.0, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaMGA16Point1DegreesToFixedLocalChatzos", name: "Sof Zman Shma (MGA, 16.1 Degrees to Fixed Local Chatzos)", #[cfg(feature = "alloc")] @@ -2084,6 +2193,7 @@ pub static SOF_ZMAN_SHMA_MGA_18_DEGREES: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(18.0), true, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaMGA18Degrees", name: "Sof Zman Shma (MGA, 18 Degrees)", #[cfg(feature = "alloc")] @@ -2104,6 +2214,7 @@ pub static SOF_ZMAN_SHMA_MGA_18_DEGREES_TO_FIXED_LOCAL_CHATZOS: ZmanPreset = Zma &ZmanPrimitive::LocalMeanTime(12.0), 3.0, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaMGA18DegreesToFixedLocalChatzos", name: "Sof Zman Shma (MGA, 18 Degrees to Fixed Local Chatzos)", #[cfg(feature = "alloc")] @@ -2124,6 +2235,7 @@ pub static SOF_ZMAN_SHMA_MGA_19_POINT_8_DEGREES: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(19.8), true, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaMGA19Point8Degrees", name: "Sof Zman Shma (MGA, 19.8 Degrees)", #[cfg(feature = "alloc")] @@ -2144,6 +2256,7 @@ pub static SOF_ZMAN_SHMA_MGA_72_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(72)), true, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaMGA72Minutes", name: "Sof Zman Shma (MGA, 72 Minutes)", #[cfg(feature = "alloc")] @@ -2164,6 +2277,7 @@ pub static SOF_ZMAN_SHMA_MGA_72_MINUTES_TO_FIXED_LOCAL_CHATZOS: ZmanPreset = Zma &ZmanPrimitive::LocalMeanTime(12.0), 3.0, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaMGA72MinutesToFixedLocalChatzos", name: "Sof Zman Shma (MGA, 72 Minutes to Fixed Local Chatzos)", #[cfg(feature = "alloc")] @@ -2184,6 +2298,7 @@ pub static SOF_ZMAN_SHMA_MGA_72_MINUTES_ZMANIS: ZmanPreset = ZmanPreset { &ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunset, 1.2), true, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaMGA72MinutesZmanis", name: "Sof Zman Shma (MGA, 72 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -2204,6 +2319,7 @@ pub static SOF_ZMAN_SHMA_MGA_90_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(90)), true, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaMGA90Minutes", name: "Sof Zman Shma (MGA, 90 Minutes)", #[cfg(feature = "alloc")] @@ -2224,6 +2340,7 @@ pub static SOF_ZMAN_SHMA_MGA_90_MINUTES_TO_FIXED_LOCAL_CHATZOS: ZmanPreset = Zma &ZmanPrimitive::LocalMeanTime(12.0), 3.0, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaMGA90MinutesToFixedLocalChatzos", name: "Sof Zman Shma (MGA, 90 Minutes to Fixed Local Chatzos)", #[cfg(feature = "alloc")] @@ -2244,6 +2361,7 @@ pub static SOF_ZMAN_SHMA_MGA_90_MINUTES_ZMANIS: ZmanPreset = ZmanPreset { &ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunset, 1.5), true, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaMGA90MinutesZmanis", name: "Sof Zman Shma (MGA, 90 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -2264,6 +2382,7 @@ pub static SOF_ZMAN_SHMA_MGA_96_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(96)), true, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaMGA96Minutes", name: "Sof Zman Shma (MGA, 96 Minutes)", #[cfg(feature = "alloc")] @@ -2284,6 +2403,7 @@ pub static SOF_ZMAN_SHMA_MGA_96_MINUTES_ZMANIS: ZmanPreset = ZmanPreset { &ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunset, 1.6), true, ), + zman_type: ZmanType::SofZmanShma, method_name: "getSofZmanShmaMGA96MinutesZmanis", name: "Sof Zman Shma (MGA, 96 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -2302,6 +2422,7 @@ pub static SOF_ZMAN_SHMA_MGA_96_MINUTES_ZMANIS: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static SOF_ZMAN_TFILA_2_HOURS_BEFORE_CHATZOS: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ChatzosHayom, Duration::from_mins(-120)), + zman_type: ZmanType::SofZmanTefila, method_name: "getSofZmanTfila2HoursBeforeChatzos", name: "Sof Zman Tfila (2 Hours Before Chatzos)", #[cfg(feature = "alloc")] @@ -2322,6 +2443,7 @@ pub static SOF_ZMAN_TFILA_ATERET_TORAH: ZmanPreset = ZmanPreset { &ZmanPrimitive::TzaisAteretTorah, false, ), + zman_type: ZmanType::SofZmanTefila, method_name: "getSofZmanTfilaAteretTorah", name: "Sof Zman Tfila (Ateret Torah)", #[cfg(feature = "alloc")] @@ -2345,6 +2467,7 @@ pub static SOF_ZMAN_TFILA_BAAL_HATANYA: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(1.583), true, ), + zman_type: ZmanType::SofZmanTefila, method_name: "getSofZmanTfilaBaalHatanya", name: "Sof Zman Tfila (Baal Hatanya)", #[cfg(feature = "alloc")] @@ -2365,6 +2488,7 @@ pub static SOF_ZMAN_TFILA_GRA: ZmanPreset = ZmanPreset { &ZmanPrimitive::ConfiguredSunset, true, ), + zman_type: ZmanType::SofZmanTefila, method_name: "getSofZmanTfilaGRA", name: "Sof Zman Tfila (GR'A)", #[cfg(feature = "alloc")] @@ -2385,6 +2509,7 @@ pub static SOF_ZMAN_TFILA_GRASUNRISE_TO_FIXED_LOCAL_CHATZOS: ZmanPreset = ZmanPr &ZmanPrimitive::LocalMeanTime(12.0), 4.0, ), + zman_type: ZmanType::SofZmanTefila, method_name: "getSofZmanTfilaGRASunriseToFixedLocalChatzos", name: "Sof Zman Tfila (GR'A, Sunrise to Fixed Local Chatzos)", #[cfg(feature = "alloc")] @@ -2405,6 +2530,7 @@ pub static SOF_ZMAN_TFILA_MGA_120_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(120)), true, ), + zman_type: ZmanType::SofZmanTefila, method_name: "getSofZmanTfilaMGA120Minutes", name: "Sof Zman Tfila (MGA, 120 Minutes)", #[cfg(feature = "alloc")] @@ -2425,6 +2551,7 @@ pub static SOF_ZMAN_TFILA_MGA_16_POINT_1_DEGREES: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(16.1), true, ), + zman_type: ZmanType::SofZmanTefila, method_name: "getSofZmanTfilaMGA16Point1Degrees", name: "Sof Zman Tfila (MGA, 16.1 Degrees)", #[cfg(feature = "alloc")] @@ -2445,6 +2572,7 @@ pub static SOF_ZMAN_TFILA_MGA_18_DEGREES: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(18.0), true, ), + zman_type: ZmanType::SofZmanTefila, method_name: "getSofZmanTfilaMGA18Degrees", name: "Sof Zman Tfila (MGA, 18 Degrees)", #[cfg(feature = "alloc")] @@ -2465,6 +2593,7 @@ pub static SOF_ZMAN_TFILA_MGA_19_POINT_8_DEGREES: ZmanPreset = ZmanPreset { &ZmanPrimitive::SunsetOffsetByDegrees(19.8), true, ), + zman_type: ZmanType::SofZmanTefila, method_name: "getSofZmanTfilaMGA19Point8Degrees", name: "Sof Zman Tfila (MGA, 19.8 Degrees)", #[cfg(feature = "alloc")] @@ -2485,6 +2614,7 @@ pub static SOF_ZMAN_TFILA_MGA_72_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(72)), true, ), + zman_type: ZmanType::SofZmanTefila, method_name: "getSofZmanTfilaMGA72Minutes", name: "Sof Zman Tfila (MGA, 72 Minutes)", #[cfg(feature = "alloc")] @@ -2505,6 +2635,7 @@ pub static SOF_ZMAN_TFILA_MGA_72_MINUTES_ZMANIS: ZmanPreset = ZmanPreset { &ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunset, 1.2), true, ), + zman_type: ZmanType::SofZmanTefila, method_name: "getSofZmanTfilaMGA72MinutesZmanis", name: "Sof Zman Tfila (MGA, 72 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -2525,6 +2656,7 @@ pub static SOF_ZMAN_TFILA_MGA_90_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(90)), true, ), + zman_type: ZmanType::SofZmanTefila, method_name: "getSofZmanTfilaMGA90Minutes", name: "Sof Zman Tfila (MGA, 90 Minutes)", #[cfg(feature = "alloc")] @@ -2545,6 +2677,7 @@ pub static SOF_ZMAN_TFILA_MGA_90_MINUTES_ZMANIS: ZmanPreset = ZmanPreset { &ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunset, 1.5), true, ), + zman_type: ZmanType::SofZmanTefila, method_name: "getSofZmanTfilaMGA90MinutesZmanis", name: "Sof Zman Tfila (MGA, 90 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -2565,6 +2698,7 @@ pub static SOF_ZMAN_TFILA_MGA_96_MINUTES: ZmanPreset = ZmanPreset { &ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(96)), true, ), + zman_type: ZmanType::SofZmanTefila, method_name: "getSofZmanTfilaMGA96Minutes", name: "Sof Zman Tfila (MGA, 96 Minutes)", #[cfg(feature = "alloc")] @@ -2585,6 +2719,7 @@ pub static SOF_ZMAN_TFILA_MGA_96_MINUTES_ZMANIS: ZmanPreset = ZmanPreset { &ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunset, 1.6), true, ), + zman_type: ZmanType::SofZmanTefila, method_name: "getSofZmanTfilaMGA96MinutesZmanis", name: "Sof Zman Tfila (MGA, 96 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -2601,6 +2736,7 @@ pub static SOF_ZMAN_TFILA_MGA_96_MINUTES_ZMANIS: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static SOLAR_MIDNIGHT: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SolarMidnight, + zman_type: ZmanType::ChatzosHalayla, method_name: "getSolarMidnight", name: "Solar Midnight", #[cfg(feature = "alloc")] @@ -2617,6 +2753,7 @@ pub static SOLAR_MIDNIGHT: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static SUN_TRANSIT: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SolarTransit, + zman_type: ZmanType::ChatzosHayom, method_name: "getSunTransit", name: "Solar Transit", #[cfg(feature = "alloc")] @@ -2631,6 +2768,7 @@ pub static SUN_TRANSIT: ZmanPreset = ZmanPreset { /// Note that although this time may be during the daytime, Kiddush Levana cannot be said during the daytime. pub static TCHILAS_ZMAN_KIDUSH_LEVANA_3_DAYS: ZmanPreset = ZmanPreset { event: ZmanPrimitive::TchilasZmanKidushLevana3Days, + zman_type: ZmanType::KidushLevana, method_name: "getTchilasZmanKidushLevana3Days", name: "Tchilas Zman Kidush Levana (3 Days)", #[cfg(feature = "alloc")] @@ -2645,6 +2783,7 @@ pub static TCHILAS_ZMAN_KIDUSH_LEVANA_3_DAYS: ZmanPreset = ZmanPreset { /// Note that although this time may be during the daytime, Kiddush Levana cannot be said during the daytime. pub static TCHILAS_ZMAN_KIDUSH_LEVANA_7_DAYS: ZmanPreset = ZmanPreset { event: ZmanPrimitive::TchilasZmanKidushLevana7Days, + zman_type: ZmanType::KidushLevana, method_name: "getTchilasZmanKidushLevana7Days", name: "Tchilas Zman Kidush Levana (7 Days)", #[cfg(feature = "alloc")] @@ -2663,6 +2802,7 @@ pub static TCHILAS_ZMAN_KIDUSH_LEVANA_7_DAYS: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static TZAIS_120_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(120)), + zman_type: ZmanType::Tzais, method_name: "getTzais120Minutes", name: "Tzais (120 Minutes)", #[cfg(feature = "alloc")] @@ -2679,6 +2819,7 @@ pub static TZAIS_120_MINUTES: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static TZAIS_120_ZMANIS: ZmanPreset = ZmanPreset { event: ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunset, 2.0), + zman_type: ZmanType::Tzais, method_name: "getTzais120Zmanis", name: "Tzais (120 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -2695,6 +2836,7 @@ pub static TZAIS_120_ZMANIS: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static TZAIS_16_POINT_1_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(16.1), + zman_type: ZmanType::Tzais, method_name: "getTzais16Point1Degrees", name: "Tzais (16.1 Degrees)", #[cfg(feature = "alloc")] @@ -2711,6 +2853,7 @@ pub static TZAIS_16_POINT_1_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static TZAIS_18_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(18.0), + zman_type: ZmanType::Tzais, method_name: "getTzais18Degrees", name: "Tzais (18 Degrees)", #[cfg(feature = "alloc")] @@ -2727,6 +2870,7 @@ pub static TZAIS_18_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static TZAIS_19_POINT_8_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(19.8), + zman_type: ZmanType::Tzais, method_name: "getTzais19Point8Degrees", name: "Tzais (19.8 Degrees)", #[cfg(feature = "alloc")] @@ -2743,6 +2887,7 @@ pub static TZAIS_19_POINT_8_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static TZAIS_26_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(26.0), + zman_type: ZmanType::Tzais, method_name: "getTzais26Degrees", name: "Tzais (26 Degrees)", #[cfg(feature = "alloc")] @@ -2761,6 +2906,7 @@ pub static TZAIS_26_DEGREES: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static TZAIS_50_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(50)), + zman_type: ZmanType::Tzais, method_name: "getTzais50Minutes", name: "Tzais (50 Minutes)", #[cfg(feature = "alloc")] @@ -2777,6 +2923,7 @@ pub static TZAIS_50_MINUTES: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static TZAIS_60_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(60)), + zman_type: ZmanType::Tzais, method_name: "getTzais60Minutes", name: "Tzais (60 Minutes)", #[cfg(feature = "alloc")] @@ -2793,6 +2940,7 @@ pub static TZAIS_60_MINUTES: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static TZAIS_72_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(72)), + zman_type: ZmanType::Tzais, method_name: "getTzais72Minutes", name: "Tzais (72 Minutes)", #[cfg(feature = "alloc")] @@ -2809,6 +2957,7 @@ pub static TZAIS_72_MINUTES: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static TZAIS_72_ZMANIS: ZmanPreset = ZmanPreset { event: ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunset, 1.2), + zman_type: ZmanType::Tzais, method_name: "getTzais72Zmanis", name: "Tzais (72 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -2825,6 +2974,7 @@ pub static TZAIS_72_ZMANIS: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static TZAIS_90_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(90)), + zman_type: ZmanType::Tzais, method_name: "getTzais90Minutes", name: "Tzais (90 Minutes)", #[cfg(feature = "alloc")] @@ -2841,6 +2991,7 @@ pub static TZAIS_90_MINUTES: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static TZAIS_90_ZMANIS: ZmanPreset = ZmanPreset { event: ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunset, 1.5), + zman_type: ZmanType::Tzais, method_name: "getTzais90Zmanis", name: "Tzais (90 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -2857,6 +3008,7 @@ pub static TZAIS_90_ZMANIS: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static TZAIS_96_MINUTES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::Offset(&ZmanPrimitive::ConfiguredSunset, Duration::from_mins(96)), + zman_type: ZmanType::Tzais, method_name: "getTzais96Minutes", name: "Tzais (96 Minutes)", #[cfg(feature = "alloc")] @@ -2871,6 +3023,7 @@ pub static TZAIS_96_MINUTES: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static TZAIS_96_ZMANIS: ZmanPreset = ZmanPreset { event: ZmanPrimitive::ZmanisOffset(&ZmanPrimitive::ConfiguredSunset, 1.6), + zman_type: ZmanType::Tzais, method_name: "getTzais96Zmanis", name: "Tzais (96 Minutes in Shaos Zmanios)", #[cfg(feature = "alloc")] @@ -2887,6 +3040,7 @@ pub static TZAIS_96_ZMANIS: ZmanPreset = ZmanPreset { /// In places such as the Arctic Circle, where there is at least one day a year when the sun does not rise and one when it does not set, this zman may not be available or cannot be calculated. pub static TZAIS_ATERET_TORAH: ZmanPreset = ZmanPreset { event: ZmanPrimitive::TzaisAteretTorah, + zman_type: ZmanType::Tzais, method_name: "getTzaisAteretTorah", name: "Tzais (Ateret Torah)", #[cfg(feature = "alloc")] @@ -2906,6 +3060,7 @@ pub static TZAIS_ATERET_TORAH: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static TZAIS_BAAL_HATANYA: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(6.0), + zman_type: ZmanType::Tzais, method_name: "getTzaisBaalHatanya", name: "Tzais (Baal Hatanya)", #[cfg(feature = "alloc")] @@ -2920,6 +3075,7 @@ pub static TZAIS_BAAL_HATANYA: ZmanPreset = ZmanPreset { /// Corresponds to 13.5 minutes after sunset (3/4 of a mil at 18 minutes per mil) in Jerusalem [around the equinox/equilux](https://kosherjava.com/2022/01/12/equinox-vs-equilux-zmanim-calculations/). Does not include the time to walk 49 amos for bain hashmashos of Rav Yosi. pub static TZAIS_GEONIM_3_POINT_7_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(3.7), + zman_type: ZmanType::Tzais, method_name: "getTzaisGeonim3Point7Degrees", name: "Tzais (Geonim, 3.7 Degrees)", #[cfg(feature = "alloc")] @@ -2934,6 +3090,7 @@ pub static TZAIS_GEONIM_3_POINT_7_DEGREES: ZmanPreset = ZmanPreset { /// Corresponds to 14 minutes after sunset: 13.5 minutes for 3/4 of an 18-minute mil, plus 30 seconds for 49 amos (bain hashmashos of Rav Yosi), in Jerusalem [around the equinox/equilux](https://kosherjava.com/2022/01/12/equinox-vs-equilux-zmanim-calculations/). pub static TZAIS_GEONIM_3_POINT_8_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(3.8), + zman_type: ZmanType::Tzais, method_name: "getTzaisGeonim3Point8Degrees", name: "Tzais (Geonim, 3.8 Degrees)", #[cfg(feature = "alloc")] @@ -2950,6 +3107,7 @@ pub static TZAIS_GEONIM_3_POINT_8_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static TZAIS_GEONIM_4_POINT_42_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(4.42), + zman_type: ZmanType::Tzais, method_name: "getTzaisGeonim4Point42Degrees", name: "Tzais (Geonim, 4.42 Degrees)", #[cfg(feature = "alloc")] @@ -2966,6 +3124,7 @@ pub static TZAIS_GEONIM_4_POINT_42_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static TZAIS_GEONIM_4_POINT_66_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(4.66), + zman_type: ZmanType::Tzais, method_name: "getTzaisGeonim4Point66Degrees", name: "Tzais (Geonim, 4.66 Degrees)", #[cfg(feature = "alloc")] @@ -2982,6 +3141,7 @@ pub static TZAIS_GEONIM_4_POINT_66_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static TZAIS_GEONIM_4_POINT_8_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(4.8), + zman_type: ZmanType::Tzais, method_name: "getTzaisGeonim4Point8Degrees", name: "Tzais (Geonim, 4.8 Degrees)", #[cfg(feature = "alloc")] @@ -2998,6 +3158,7 @@ pub static TZAIS_GEONIM_4_POINT_8_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static TZAIS_GEONIM_5_POINT_95_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(5.95), + zman_type: ZmanType::Tzais, method_name: "getTzaisGeonim5Point95Degrees", name: "Tzais (Geonim, 5.95 Degrees)", #[cfg(feature = "alloc")] @@ -3014,6 +3175,7 @@ pub static TZAIS_GEONIM_5_POINT_95_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static TZAIS_GEONIM_6_POINT_45_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(6.45), + zman_type: ZmanType::Tzais, method_name: "getTzaisGeonim6Point45Degrees", name: "Tzais (Geonim, 6.45 Degrees)", #[cfg(feature = "alloc")] @@ -3030,6 +3192,7 @@ pub static TZAIS_GEONIM_6_POINT_45_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static TZAIS_GEONIM_7_POINT_083_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(7.083333333333333), + zman_type: ZmanType::Tzais, method_name: "getTzaisGeonim7Point083Degrees", name: "Tzais (Geonim, 7.083 Degrees)", #[cfg(feature = "alloc")] @@ -3046,6 +3209,7 @@ pub static TZAIS_GEONIM_7_POINT_083_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static TZAIS_GEONIM_7_POINT_67_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(7.67), + zman_type: ZmanType::Tzais, method_name: "getTzaisGeonim7Point67Degrees", name: "Tzais (Geonim, 7.67 Degrees)", #[cfg(feature = "alloc")] @@ -3062,6 +3226,7 @@ pub static TZAIS_GEONIM_7_POINT_67_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static TZAIS_GEONIM_8_POINT_5_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(8.5), + zman_type: ZmanType::Tzais, method_name: "getTzaisGeonim8Point5Degrees", name: "Tzais (Geonim, 8.5 Degrees)", #[cfg(feature = "alloc")] @@ -3078,6 +3243,7 @@ pub static TZAIS_GEONIM_8_POINT_5_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static TZAIS_GEONIM_9_POINT_3_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(9.3), + zman_type: ZmanType::Tzais, method_name: "getTzaisGeonim9Point3Degrees", name: "Tzais (Geonim, 9.3 Degrees)", #[cfg(feature = "alloc")] @@ -3094,6 +3260,7 @@ pub static TZAIS_GEONIM_9_POINT_3_DEGREES: ZmanPreset = ZmanPreset { /// At some northern and southern locations, this zman may not be available or cannot be calculated if the sun does not reach low enough below the horizon. pub static TZAIS_GEONIM_9_POINT_75_DEGREES: ZmanPreset = ZmanPreset { event: ZmanPrimitive::SunsetOffsetByDegrees(9.75), + zman_type: ZmanType::Tzais, method_name: "getTzaisGeonim9Point75Degrees", name: "Tzais (Geonim, 9.75 Degrees)", #[cfg(feature = "alloc")] diff --git a/tools/dsl.py b/tools/dsl.py index b602b62..15826ae 100644 --- a/tools/dsl.py +++ b/tools/dsl.py @@ -177,12 +177,11 @@ "getTchilasZmanKidushLevana7Days", ] -ZmanimType = Literal[ +ZmanType = Literal[ "twilight", # Start and End of Astronomical, Civil, and Nautical Twilight "alos", "misheyakir", "netz", - "sof_zman_shema", "sof_zman_shma", "sof_zman_tefila", "sof_zman_achilas_chametz", @@ -197,7 +196,6 @@ "shkiya", "tzais", "kidush_levana", - "molad", "chatzos_halayla", ] @@ -575,7 +573,7 @@ class Zman(BaseModel): id: ZmanimMethod """The KosherJava getter this preset matches, such as `getAlos120Zmanis`.""" - type_: ZmanimType + type_: ZmanType """The broad zman category used for grouping.""" name: str """The human-readable display name.""" diff --git a/tools/generate-interop.py b/tools/generate-interop.py new file mode 100644 index 0000000..bdc501b --- /dev/null +++ b/tools/generate-interop.py @@ -0,0 +1,261 @@ +from __future__ import annotations + +import re +import subprocess +from pathlib import Path + +from dsl import ZMAN, Zman, ZmanType +from typing import get_args + + +SCRIPT_DIR = Path(__file__).parent +OUTPUT_DIR = SCRIPT_DIR.parent / "interop" / "src" / "generated" + +NAMES = { + "getSunrise": "ELEVATION_ADJUSTED_SUNRISE", + "getSunset": "ELEVATION_ADJUSTED_SUNSET", +} + + +def method_to_const(method_name: str) -> str: + if not method_name.startswith("get"): + raise ValueError(f"Expected Java getter name, got {method_name!r}") + + name = method_name[3:] + with_underscores = re.sub(r"([a-z0-9])([A-Z])", r"\1_\2", name) + with_underscores = re.sub(r"([a-zA-Z])(\d)", r"\1_\2", with_underscores) + with_underscores = re.sub(r"(\d)([a-zA-Z])", r"\1_\2", with_underscores) + return with_underscores.upper() + + +def snake_to_pascal(value: str) -> str: + return "".join(part.capitalize() for part in value.split("_")) + + +def ordered_zman_types(presets: list[tuple[str, str, str, bool]]) -> list[str]: + """DSL order, restricted to types that appear on at least one preset.""" + used = {zman_type for _, _, zman_type, _ in presets} + return [zman_type for zman_type in get_args(ZmanType) if zman_type in used] + + +def collect_presets() -> list[tuple[str, str, str, bool]]: + """Return sorted (const_name, method_name, zman_type, deprecated) tuples.""" + presets: list[tuple[str, str, str, bool]] = [] + seen_consts: set[str] = set() + + for zman in ZMAN: + method_name = zman.id + if not isinstance(zman, Zman): + raise TypeError(f"{method_name} is not a DSL Zman") + if zman.zman is None: + raise ValueError(f"{method_name} has no DSL primitive") + + if method_name in NAMES: + const_name = NAMES[method_name] + else: + const_name = method_to_const(method_name) + if const_name in seen_consts: + raise ValueError(f"Duplicate preset constant {const_name}") + seen_consts.add(const_name) + presets.append((const_name, method_name, zman.type_, zman.deprecated)) + + presets.sort(key=lambda preset: preset[0]) + return presets + + +def generate_zman_preset_bridge(presets: list[tuple[str, str, str, bool]]) -> str: + variants = "\n ".join( + f"{snake_to_pascal(const_name)}," for const_name, _, _, _ in presets + ) + zman_types = ordered_zman_types(presets) + type_variants = "\n ".join( + f"{snake_to_pascal(zman_type)}," for zman_type in zman_types + ) + type_match_arms = "\n ".join( + f"kosher_rust::zmanim::ZmanType::{snake_to_pascal(zman_type)} => " + f"ZmanType::{snake_to_pascal(zman_type)}," + for zman_type in zman_types + ) + return f"""//! Generated zman preset diplomat bridge. +#![allow(missing_docs, dead_code)] + +#[diplomat::bridge] +mod ffi {{ + use core::fmt::Write; + + use diplomat_runtime::DiplomatWrite; + + use crate::generated::preset_dispatch::{{PRESET_METADATA, ZMAN_PRESET_COUNT}}; + + /// Stable identifier for a generated zman preset. + pub enum ZmanPresetId {{ + {variants} + }} + + /// Broad category of a zman preset. + pub enum ZmanType {{ + {type_variants} + }} + + fn to_ffi_zman_type(zman_type: kosher_rust::zmanim::ZmanType) -> ZmanType {{ + match zman_type {{ + {type_match_arms} + }} + }} + + /// Returns the number of available presets. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn preset_count() -> u32 {{ + u32::try_from(ZMAN_PRESET_COUNT).unwrap_or(u32::MAX) + }} + + /// Writes the display name for a preset. Returns false when the preset is unknown. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn preset_name(preset: ZmanPresetId, write: &mut DiplomatWrite) -> bool {{ + PRESET_METADATA + .get(preset as usize) + .map(|meta| write!(write, "{{}}", meta.name).is_ok()) + .unwrap_or(false) + }} + + /// Returns whether a preset is deprecated. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn preset_deprecated(preset: ZmanPresetId) -> bool {{ + PRESET_METADATA + .get(preset as usize) + .is_some_and(|meta| meta.deprecated) + }} + + /// Writes the KosherJava-style method name for a preset. Returns false when unknown. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn preset_method_name(preset: ZmanPresetId, write: &mut DiplomatWrite) -> bool {{ + PRESET_METADATA + .get(preset as usize) + .map(|meta| write!(write, "{{}}", meta.method_name).is_ok()) + .unwrap_or(false) + }} + + /// Returns the broad category for a preset. + #[diplomat::attr(not(supports = free_functions), disable)] + pub fn preset_zman_type(preset: ZmanPresetId) -> ZmanType {{ + to_ffi_zman_type(PRESET_METADATA[preset as usize].zman_type) + }} + + /// Dart entry point: construct once and call instance methods. + #[diplomat::cfg(not(supports = free_functions))] + #[diplomat::opaque] + pub struct ZmanPresets(u8); + + impl ZmanPresets {{ + #[diplomat::attr(*, constructor)] + pub fn new() -> Box {{ + Box::new(ZmanPresets(0)) + }} + + pub fn preset_count(&self) -> u32 {{ + u32::try_from(ZMAN_PRESET_COUNT).unwrap_or(u32::MAX) + }} + + pub fn preset_name(&self, preset: ZmanPresetId, write: &mut DiplomatWrite) -> bool {{ + PRESET_METADATA + .get(preset as usize) + .map(|meta| write!(write, "{{}}", meta.name).is_ok()) + .unwrap_or(false) + }} + + pub fn preset_deprecated(&self, preset: ZmanPresetId) -> bool {{ + PRESET_METADATA + .get(preset as usize) + .is_some_and(|meta| meta.deprecated) + }} + + pub fn preset_method_name(&self, preset: ZmanPresetId, write: &mut DiplomatWrite) -> bool {{ + PRESET_METADATA + .get(preset as usize) + .map(|meta| write!(write, "{{}}", meta.method_name).is_ok()) + .unwrap_or(false) + }} + + pub fn preset_zman_type(&self, preset: ZmanPresetId) -> ZmanType {{ + to_ffi_zman_type(PRESET_METADATA[preset as usize].zman_type) + }} + }} +}} +""" + + +def generate_dispatch(presets: list[tuple[str, str, str, bool]]) -> str: + arms = "\n ".join( + f"{index} => Some(&presets::{const_name})," + for index, (const_name, _, _, _) in enumerate(presets) + ) + meta_lines = [] + for const_name, method_name, zman_type, deprecated in presets: + dep = "true" if deprecated else "false" + type_variant = snake_to_pascal(zman_type) + meta_lines.append( + " PresetMetadata {\n" + f' method_name: "{method_name}",\n' + f" name: presets::{const_name}.name,\n" + f" zman_type: ZmanType::{type_variant},\n" + f" deprecated: {dep},\n" + " }" + ) + metadata_entries = ",\n".join(meta_lines) + + return f"""//! Generated by tools/generate-interop.py. Do not edit by hand. +#![allow(missing_docs, dead_code)] + +use kosher_rust::zmanim::{{ZmanPreset, ZmanType, presets}}; + +/// Stable count of generated zman presets. +pub const ZMAN_PRESET_COUNT: usize = {len(presets)}; + +/// Metadata for a zman preset (static strings, no closures). +pub struct PresetMetadata {{ + pub method_name: &'static str, + pub name: &'static str, + pub zman_type: ZmanType, + pub deprecated: bool, +}} + +/// Static metadata table, indexed by preset discriminant order. +pub static PRESET_METADATA: [PresetMetadata; {len(presets)}] = [ +{metadata_entries} +]; + +/// Looks up a preset static by stable index (matches [`ZmanPresetId`] discriminant order). +pub fn preset_by_index(index: usize) -> Option<&'static ZmanPreset> {{ + match index {{ + {arms} + _ => None, + }} +}} +""" + + +def generate_mod() -> str: + return """//! Generated module root. + +pub mod preset_dispatch; +""" + + +def main() -> None: + presets = collect_presets() + OUTPUT_DIR.mkdir(parents=True, exist_ok=True) + + (OUTPUT_DIR / "mod.rs").write_text(generate_mod(), encoding="utf-8", newline="\n") + (OUTPUT_DIR.parent / "zman_preset.rs").write_text( + generate_zman_preset_bridge(presets), encoding="utf-8", newline="\n" + ) + (OUTPUT_DIR / "preset_dispatch.rs").write_text( + generate_dispatch(presets), encoding="utf-8", newline="\n" + ) + + print(f"Wrote interop generated files to {OUTPUT_DIR} ({len(presets)} presets).") + subprocess.run(["cargo", "fmt", "-p", "interop"], cwd=SCRIPT_DIR.parent, check=True) + + +if __name__ == "__main__": + main() diff --git a/tools/generate-rust.py b/tools/generate-rust.py index 39822bf..125ec30 100644 --- a/tools/generate-rust.py +++ b/tools/generate-rust.py @@ -186,6 +186,7 @@ def preset_block( const_name: str, method_name: str, event: str, + zman_type: str, preset_name: str, description: str, deprecated: bool, @@ -196,6 +197,7 @@ def preset_block( return f"""{doc} pub static {const_name}: ZmanPreset = ZmanPreset {{ event: {event}, + zman_type: ZmanType::{snake_to_pascal(zman_type)}, method_name: {json.dumps(method_name)}, name: {name_literal}, #[cfg(feature = "alloc")] @@ -271,6 +273,7 @@ def generate(docs: dict[str, str]) -> str: const_name, method_name, rust_primitive(zman.zman), + zman.type_, zman.name, docs[method_name], zman.deprecated, @@ -294,7 +297,7 @@ def generate(docs: dict[str, str]) -> str: #[cfg(feature = "alloc")] use alloc::string::{String, ToString}; -use crate::zmanim::ZmanPreset; +use crate::zmanim::{ZmanPreset, ZmanType}; use crate::zmanim::primitives::ZmanPrimitive; use jiff::SignedDuration as Duration;