validateTaiyinNativeCompatibility function
Validates the native metadata available before any optional symbol lookup.
This stays independent of generated bindings so compatibility behavior can be tested without loading a platform-specific dynamic library.
The Dart package exposes its split-date time service and its Chinese
calendar and Ganzhi services as required parts of every
EphemerisContext, so it requires split-time and Chinese-calendar support.
BaZi and Ziwei validate their separately loaded native modules instead of
consulting the core capability mask.
Implementation
void validateTaiyinNativeCompatibility({
required int abiVersion,
required int capabilities,
}) {
if (abiVersion != taiyinSupportedAbiVersion) {
throw StateError(
'Unsupported Taiyin C ABI $abiVersion; '
'this package supports ABI $taiyinSupportedAbiVersion.',
);
}
if ((capabilities & taiyinSplitTimeCapability) == 0) {
throw StateError(
'The loaded Taiyin library does not provide the split-time capability '
'required by this package.',
);
}
if ((capabilities & taiyinChineseCalendarCapability) == 0) {
throw StateError(
'The loaded Taiyin library does not provide the Chinese-calendar '
'capability required by this package.',
);
}
}