mirror of
https://github.com/morluto/rea.git
synced 2026-12-05 22:41:36 +00:00
refactor(plist): share projected scalar limitations (#16392)
This commit is contained in:
1 parent
f7ee741fdb
commit
542c07ab98
3 files changed
+38
-45
No files matched your search
@@ -38,13 +38,7 @@ import {
|
||||
AnalysisTargetFailureError,
|
||||
unrecognizedTarget,
|
||||
} from "../../domain/analysisErrorCore.js";
|
||||
import {
|
||||
binaryDatePrecisionOverlapLimitation,
|
||||
negativeZeroRealLimitation,
|
||||
nonFiniteRealLimitation,
|
||||
unknownDateLimitation,
|
||||
unknownScalarLimitation,
|
||||
} from "../../domain/apple/plistValue.js";
|
||||
import { projectedScalarLimitations } from "../../domain/apple/plistValue.js";
|
||||
import { createPlistNumberProjection } from "../../domain/apple/plistNumbers.js";
|
||||
import {
|
||||
scanBinaryPlistScalars,
|
||||
@@ -164,26 +158,15 @@ export const decodeKeyedArchiveBytes = (
|
||||
...graph.limitations,
|
||||
...numbers.limitations(),
|
||||
...plistDuplicateKeyLimitations(parsed.duplicateKeys),
|
||||
...(nonFiniteRealCount === 0
|
||||
? []
|
||||
: [nonFiniteRealLimitation(nonFiniteRealCount)]),
|
||||
...(negativeZeroRealCount === 0
|
||||
? []
|
||||
: [negativeZeroRealLimitation(negativeZeroRealCount)]),
|
||||
...(unknownDateCount === 0
|
||||
? []
|
||||
: [unknownDateLimitation(unknownDateCount)]),
|
||||
...(binaryExpansion === undefined ||
|
||||
binaryExpansion.datePrecisionOverlapCount === 0
|
||||
? []
|
||||
: [
|
||||
binaryDatePrecisionOverlapLimitation(
|
||||
binaryExpansion.datePrecisionOverlapCount,
|
||||
),
|
||||
]),
|
||||
...(unknownScalarCount === 0
|
||||
? []
|
||||
: [unknownScalarLimitation(unknownScalarCount)]),
|
||||
...projectedScalarLimitations(
|
||||
{
|
||||
nonFiniteRealCount,
|
||||
negativeZeroRealCount,
|
||||
unknownDateCount,
|
||||
unknownScalarCount,
|
||||
},
|
||||
binaryExpansion?.datePrecisionOverlapCount,
|
||||
),
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
@@ -79,6 +79,33 @@ export const negativeZeroReal = (): Record<string, JsonValue> => ({
|
||||
export const negativeZeroRealLimitation = (count: number): string =>
|
||||
`${String(count)} negative-zero real value(s) are reported as { "$plist_type": "real", "value": "-0" } because a JSON number cannot carry the sign of zero.`;
|
||||
|
||||
/** Preserve the reader's limitation order for projected scalars. */
|
||||
export const projectedScalarLimitations = (
|
||||
projected: Omit<ProjectedPlistValue, "value">,
|
||||
datePrecisionOverlapCount = 0,
|
||||
): string[] => {
|
||||
const limitations: string[] = [];
|
||||
const {
|
||||
nonFiniteRealCount,
|
||||
negativeZeroRealCount,
|
||||
unknownDateCount,
|
||||
unknownScalarCount,
|
||||
} = projected;
|
||||
if (nonFiniteRealCount !== 0)
|
||||
limitations.push(nonFiniteRealLimitation(nonFiniteRealCount));
|
||||
if (negativeZeroRealCount !== 0)
|
||||
limitations.push(negativeZeroRealLimitation(negativeZeroRealCount));
|
||||
if (unknownDateCount !== 0)
|
||||
limitations.push(unknownDateLimitation(unknownDateCount));
|
||||
if (datePrecisionOverlapCount !== 0)
|
||||
limitations.push(
|
||||
binaryDatePrecisionOverlapLimitation(datePrecisionOverlapCount),
|
||||
);
|
||||
if (unknownScalarCount !== 0)
|
||||
limitations.push(unknownScalarLimitation(unknownScalarCount));
|
||||
return limitations;
|
||||
};
|
||||
|
||||
/**
|
||||
* Project a decoded plist into JSON. Data, dates, retained big integers and
|
||||
* known non-finite reals become explicit `$plist_type` objects. Unresolved XML
|
||||
|
||||
@@ -16,11 +16,9 @@ import {
|
||||
binaryDatePrecisionOverlapLimitation,
|
||||
negativeZeroReal,
|
||||
negativeZeroRealLimitation,
|
||||
nonFiniteRealLimitation,
|
||||
projectPlistValue,
|
||||
projectedScalarLimitations,
|
||||
MAX_NATIVE_PLIST_NESTING_DEPTH,
|
||||
unknownDateLimitation,
|
||||
unknownScalarLimitation,
|
||||
type ProjectedPlistValue,
|
||||
PlistNestingLimitError,
|
||||
} from "../../domain/apple/plistValue.js";
|
||||
@@ -429,21 +427,6 @@ export const parsePlistBinary = (
|
||||
}
|
||||
};
|
||||
|
||||
const projectedScalarLimitations = (
|
||||
projected: ProjectedPlistValue,
|
||||
): string[] => [
|
||||
...(projected.nonFiniteRealCount === 0
|
||||
? []
|
||||
: [nonFiniteRealLimitation(projected.nonFiniteRealCount)]),
|
||||
...negativeZeroLimitations(projected.negativeZeroRealCount),
|
||||
...(projected.unknownDateCount === 0
|
||||
? []
|
||||
: [unknownDateLimitation(projected.unknownDateCount)]),
|
||||
...(projected.unknownScalarCount === 0
|
||||
? []
|
||||
: [unknownScalarLimitation(projected.unknownScalarCount)]),
|
||||
];
|
||||
|
||||
const negativeZeroLimitations = (count: number): string[] =>
|
||||
count === 0 ? [] : [negativeZeroRealLimitation(count)];
|
||||
|
||||
|
||||
Reference in new issue
Block a user