diff --git a/CHANGELOG.md b/CHANGELOG.md index bdf906f..57034f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,23 @@ contract corrections before stable `v1.0.0`. ## [Unreleased] -No user-visible changes yet. +### Changed + +- Replace the capture/displays PowerShell process with a bundled command-scoped + native C++ executable. Retain the capture protocol, desktop admission, before/after + environment checks, independent PNG validation and transactional archive publication. + Input execution continues to use Windows PowerShell 5.1. +- Build the native helper with MinGW-w64 or CMake/Visual Studio; installed packages + include the executable and JSON library license and need no compiler. +- Add a controlled-window CLI benchmark with alternating baseline/candidate runs + and independent pixel verification. + +- Make the cu automation skill explicitly prefer Pi codemode for observation and + optional image delivery in one call, including reuse of action checkpoint images. +- Document collection-only delivery, batched action-file writing, background-task + handling, and recovery when image delivery fails after a completed command. +- Correct the skill's checkpoint key list and explain why move-then-click plans + discard the second coordinate action. ## [1.0.0-preview.1] - 2026-08-14 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e6226c2..dcb17e6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,6 +24,9 @@ Required tooling: - Node.js 22.19.0 or newer - Windows PowerShell 5.1 - npm as supplied with the selected Node.js installation +- A matching Windows C++ compiler: MinGW-w64 GCC, or CMake with Visual Studio C++ + build tools. `CU_CXX` may select an explicit MinGW compiler for source builds. + Installed packages contain the compiled helper and require no compiler. Set up a checkout: @@ -55,7 +58,8 @@ new parallel implementations. ## Testing The repository test aggregator is an active Windows integration suite, not a -side-effect-free metadata check. It loads PowerShell helper paths and must run only in a +side-effect-free metadata check. It executes the native capture helper and PowerShell +input/reference helpers and must run only in a suitable Windows test environment: ```powershell diff --git a/README.md b/README.md index 6e9ed38..6fb89e6 100644 --- a/README.md +++ b/README.md @@ -64,8 +64,8 @@ Keep observation authority, input delivery, and application outcomes separate. - **Transactional capture archive**: validated PNG/sidecar bundles, create-once publication, rollback-before/forward-after recovery, quotas, history, and explicit cleanup. -- **Command-scoped Windows helpers**: stock Windows PowerShell 5.1 helpers exist only - for the command that needs desktop topology, observation, or input. +- **Command-scoped Windows helpers**: a bundled native EXE handles desktop topology + and capture; Windows PowerShell 5.1 handles input. Each helper exits with its command. - **Stable machine output**: versioned JSON receipts, sanitized error envelopes, and fixed exit-code meanings for shell automation. @@ -75,7 +75,7 @@ Keep observation authority, input delivery, and application outcomes separate. - Windows with an interactive default desktop - Node.js `22.19.0` or newer -- Windows PowerShell 5.1 +- Windows PowerShell 5.1 for input execution (capture/displays run directly as native code) - Permission to observe and control the selected desktop content Locked, secure, unavailable, or elevation-bypass desktops fail closed. `cu` does not diff --git a/docs/README.md b/docs/README.md index c12e964..0ce91f6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -32,6 +32,17 @@ for exact schemas, state transitions, and design decisions. - [Transactional Observation Archive and Effect Recovery](specification/v1/decisions/005-transactional-observation-archive.md) - [Witness-Validated Control-Record Replacement](specification/v1/decisions/006-witness-validated-control-record-replacement.md) +## Research and Product Analysis + +These documents record dated findings and proposals, not normative contracts. + +- [Efficiency and Pi Image Delivery](research/efficiency-and-pi-image-delivery.md) +- [Observe Latency Hill Climb](research/observe-latency-hillclimb.md) +- [PowerShell 7 and DLL Observe Experiments](research/observe-powershell7-and-dll.md) +- [Observe without PowerShell: Startup Comparison](research/observe-without-powershell.md) +- [Native Capture Helper: Implementation and Measurements](research/observe-native-helper.md) +- [Product Boundaries: agent-desktop and Codex](research/product-boundaries-agent-desktop-codex.md) + ## Project Operations - [Contributing](../CONTRIBUTING.md) diff --git a/docs/releasing.md b/docs/releasing.md index 60f4d5c..05b6831 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -87,7 +87,7 @@ node dist/src/cli.js help --json Before making automated tests a required hosted check, add or identify a dedicated CI-safe test command whose environment and effects are explicit. The current `npm test` -is an active Windows integration suite that loads PowerShell helper paths; it is not a +is an active Windows integration suite that executes native and PowerShell helpers; it is not a side-effect-free metadata preflight and may require an interactive desktop. Run it on an authorized Windows integration host, not blindly on a generic hosted runner. @@ -147,6 +147,8 @@ unscoped package name `cu` is already owned by another project. Before npm publi `dist/helper/`, `README.md`, `LICENSE`, and required package metadata. - [ ] Exclude tests, source TypeScript, local reviews, fixtures, `.cu/`, and `NUL`. - [ ] Remove `private: true` only in the reviewed npm-publishing change. +- [ ] Build the native capture executable for each advertised architecture using a + matching MinGW-w64 or Visual Studio C++ toolchain; include its JSON library license. - [ ] Run `npm pack --dry-run --json` and inspect every proposed path. - [ ] Run `npm pack --json --pack-destination ` to create the exact candidate `.tgz` outside the checkout, then inspect its file list and SHA-256. diff --git a/docs/research/data/observe-executable-startup-20261109.json b/docs/research/data/observe-executable-startup-20261109.json new file mode 100644 index 0000000..8084bbd --- /dev/null +++ b/docs/research/data/observe-executable-startup-20261109.json @@ -0,0 +1,543 @@ +{ + "note": "Fresh process, warm filesystem caches. Empty programs only; no capture, PNG, protocol, archive, or validation. Concurrent game/background load is not controlled.", + "rounds": 20, + "binaries": { + "managedBytes": 3584, + "nativeBytes": 14848 + }, + "samples": [ + { + "pair": 0, + "name": "ps51", + "totalMs": 189.21670000000006 + }, + { + "pair": 0, + "name": "ps7", + "totalMs": 237.77279999999996 + }, + { + "pair": 0, + "name": "framework-exe", + "totalMs": 61.19589999999994 + }, + { + "pair": 0, + "name": "native-exe", + "totalMs": 28.440399999999954 + }, + { + "pair": 0, + "name": "node", + "totalMs": 90.3900000000001 + }, + { + "pair": 1, + "name": "ps7", + "totalMs": 225.26279999999997 + }, + { + "pair": 1, + "name": "framework-exe", + "totalMs": 48.86759999999981 + }, + { + "pair": 1, + "name": "native-exe", + "totalMs": 25.95569999999998 + }, + { + "pair": 1, + "name": "node", + "totalMs": 88.3714 + }, + { + "pair": 1, + "name": "ps51", + "totalMs": 187.10860000000002 + }, + { + "pair": 2, + "name": "framework-exe", + "totalMs": 54.32849999999962 + }, + { + "pair": 2, + "name": "native-exe", + "totalMs": 25.290399999999863 + }, + { + "pair": 2, + "name": "node", + "totalMs": 89.97270000000026 + }, + { + "pair": 2, + "name": "ps51", + "totalMs": 181.95820000000003 + }, + { + "pair": 2, + "name": "ps7", + "totalMs": 227.57140000000027 + }, + { + "pair": 3, + "name": "native-exe", + "totalMs": 33.03890000000001 + }, + { + "pair": 3, + "name": "node", + "totalMs": 90.11000000000013 + }, + { + "pair": 3, + "name": "ps51", + "totalMs": 181.10390000000007 + }, + { + "pair": 3, + "name": "ps7", + "totalMs": 235.51710000000003 + }, + { + "pair": 3, + "name": "framework-exe", + "totalMs": 56.22539999999981 + }, + { + "pair": 4, + "name": "node", + "totalMs": 90.55250000000024 + }, + { + "pair": 4, + "name": "ps51", + "totalMs": 180.85999999999967 + }, + { + "pair": 4, + "name": "ps7", + "totalMs": 247.1646999999998 + }, + { + "pair": 4, + "name": "framework-exe", + "totalMs": 52.2801000000004 + }, + { + "pair": 4, + "name": "native-exe", + "totalMs": 25.015399999999772 + }, + { + "pair": 5, + "name": "node", + "totalMs": 91.06760000000031 + }, + { + "pair": 5, + "name": "native-exe", + "totalMs": 28.873999999999796 + }, + { + "pair": 5, + "name": "framework-exe", + "totalMs": 49.95590000000038 + }, + { + "pair": 5, + "name": "ps7", + "totalMs": 225.08640000000014 + }, + { + "pair": 5, + "name": "ps51", + "totalMs": 180.84220000000005 + }, + { + "pair": 6, + "name": "ps51", + "totalMs": 205.42360000000008 + }, + { + "pair": 6, + "name": "node", + "totalMs": 101.65869999999995 + }, + { + "pair": 6, + "name": "native-exe", + "totalMs": 30.115700000000288 + }, + { + "pair": 6, + "name": "framework-exe", + "totalMs": 53.39100000000053 + }, + { + "pair": 6, + "name": "ps7", + "totalMs": 233.83700000000044 + }, + { + "pair": 7, + "name": "ps7", + "totalMs": 238.88190000000031 + }, + { + "pair": 7, + "name": "ps51", + "totalMs": 195.70339999999942 + }, + { + "pair": 7, + "name": "node", + "totalMs": 92.23399999999947 + }, + { + "pair": 7, + "name": "native-exe", + "totalMs": 25.541299999999865 + }, + { + "pair": 7, + "name": "framework-exe", + "totalMs": 54.466599999999744 + }, + { + "pair": 8, + "name": "framework-exe", + "totalMs": 47.418000000000575 + }, + { + "pair": 8, + "name": "ps7", + "totalMs": 242.70959999999923 + }, + { + "pair": 8, + "name": "ps51", + "totalMs": 186.10530000000017 + }, + { + "pair": 8, + "name": "node", + "totalMs": 94.8762999999999 + }, + { + "pair": 8, + "name": "native-exe", + "totalMs": 24.646999999999935 + }, + { + "pair": 9, + "name": "native-exe", + "totalMs": 25.241299999999683 + }, + { + "pair": 9, + "name": "framework-exe", + "totalMs": 51.2493000000004 + }, + { + "pair": 9, + "name": "ps7", + "totalMs": 258.54029999999966 + }, + { + "pair": 9, + "name": "ps51", + "totalMs": 181.80000000000018 + }, + { + "pair": 9, + "name": "node", + "totalMs": 93.64660000000003 + }, + { + "pair": 10, + "name": "ps51", + "totalMs": 180.1314000000002 + }, + { + "pair": 10, + "name": "ps7", + "totalMs": 226.13150000000041 + }, + { + "pair": 10, + "name": "framework-exe", + "totalMs": 48.00919999999951 + }, + { + "pair": 10, + "name": "native-exe", + "totalMs": 26.669199999999364 + }, + { + "pair": 10, + "name": "node", + "totalMs": 89.6216000000004 + }, + { + "pair": 11, + "name": "ps7", + "totalMs": 226.76230000000032 + }, + { + "pair": 11, + "name": "framework-exe", + "totalMs": 49.589500000000044 + }, + { + "pair": 11, + "name": "native-exe", + "totalMs": 25.65229999999974 + }, + { + "pair": 11, + "name": "node", + "totalMs": 92.30079999999998 + }, + { + "pair": 11, + "name": "ps51", + "totalMs": 184.7439999999997 + }, + { + "pair": 12, + "name": "framework-exe", + "totalMs": 51.22400000000016 + }, + { + "pair": 12, + "name": "native-exe", + "totalMs": 26.48990000000049 + }, + { + "pair": 12, + "name": "node", + "totalMs": 88.57679999999982 + }, + { + "pair": 12, + "name": "ps51", + "totalMs": 182.6823999999997 + }, + { + "pair": 12, + "name": "ps7", + "totalMs": 227.41449999999895 + }, + { + "pair": 13, + "name": "native-exe", + "totalMs": 24.608500000000276 + }, + { + "pair": 13, + "name": "node", + "totalMs": 88.5018999999993 + }, + { + "pair": 13, + "name": "ps51", + "totalMs": 183.8197 + }, + { + "pair": 13, + "name": "ps7", + "totalMs": 226.54300000000148 + }, + { + "pair": 13, + "name": "framework-exe", + "totalMs": 51.5601000000006 + }, + { + "pair": 14, + "name": "node", + "totalMs": 89.98689999999988 + }, + { + "pair": 14, + "name": "ps51", + "totalMs": 180.3262999999988 + }, + { + "pair": 14, + "name": "ps7", + "totalMs": 231.32010000000082 + }, + { + "pair": 14, + "name": "framework-exe", + "totalMs": 49.315599999999904 + }, + { + "pair": 14, + "name": "native-exe", + "totalMs": 23.98240000000078 + }, + { + "pair": 15, + "name": "node", + "totalMs": 88.52899999999863 + }, + { + "pair": 15, + "name": "native-exe", + "totalMs": 28.850099999999657 + }, + { + "pair": 15, + "name": "framework-exe", + "totalMs": 47.73250000000007 + }, + { + "pair": 15, + "name": "ps7", + "totalMs": 229.22110000000066 + }, + { + "pair": 15, + "name": "ps51", + "totalMs": 188.44690000000082 + }, + { + "pair": 16, + "name": "ps51", + "totalMs": 181.4947000000011 + }, + { + "pair": 16, + "name": "node", + "totalMs": 92.48739999999998 + }, + { + "pair": 16, + "name": "native-exe", + "totalMs": 23.811799999999494 + }, + { + "pair": 16, + "name": "framework-exe", + "totalMs": 47.8768 + }, + { + "pair": 16, + "name": "ps7", + "totalMs": 222.73090000000047 + }, + { + "pair": 17, + "name": "ps7", + "totalMs": 226.8869999999988 + }, + { + "pair": 17, + "name": "ps51", + "totalMs": 182.63500000000022 + }, + { + "pair": 17, + "name": "node", + "totalMs": 89.02579999999944 + }, + { + "pair": 17, + "name": "native-exe", + "totalMs": 26.722899999998845 + }, + { + "pair": 17, + "name": "framework-exe", + "totalMs": 52.341199999998935 + }, + { + "pair": 18, + "name": "framework-exe", + "totalMs": 46.233900000001086 + }, + { + "pair": 18, + "name": "ps7", + "totalMs": 262.8785000000007 + }, + { + "pair": 18, + "name": "ps51", + "totalMs": 184.77419999999984 + }, + { + "pair": 18, + "name": "node", + "totalMs": 93.23660000000018 + }, + { + "pair": 18, + "name": "native-exe", + "totalMs": 23.14379999999983 + }, + { + "pair": 19, + "name": "native-exe", + "totalMs": 23.796700000000783 + }, + { + "pair": 19, + "name": "framework-exe", + "totalMs": 45.835399999999936 + }, + { + "pair": 19, + "name": "ps7", + "totalMs": 218.6948999999986 + }, + { + "pair": 19, + "name": "ps51", + "totalMs": 178.2530000000006 + }, + { + "pair": 19, + "name": "node", + "totalMs": 88.568299999999 + } + ], + "medians": { + "ps51": 182.65869999999995, + "ps7": 228.39625000000046, + "framework-exe": 50.58995000000027, + "native-exe": 25.596799999999803, + "node": 90.25000000000011 + }, + "comparisons": [ + { + "baseline": "ps51", + "candidate": "ps7", + "pairedMedianSavedMs": -44.492049999998926, + "pairsWon": 0 + }, + { + "baseline": "ps51", + "candidate": "framework-exe", + "pairedMedianSavedMs": 132.19090000000006, + "pairsWon": 20 + }, + { + "baseline": "ps51", + "candidate": "native-exe", + "pairedMedianSavedMs": 157.1753500000009, + "pairsWon": 20 + }, + { + "baseline": "ps51", + "candidate": "node", + "pairedMedianSavedMs": 91.76154999999972, + "pairsWon": 20 + } + ] +} diff --git a/docs/research/data/observe-native-20261109.json b/docs/research/data/observe-native-20261109.json new file mode 100644 index 0000000..81d63d3 --- /dev/null +++ b/docs/research/data/observe-native-20261109.json @@ -0,0 +1,891 @@ +{ + "date": "2026-11-09", + "note": "Only repository-owned fixture screenshots; complete CLI time; concurrent background/game load not controlled. Native C++ vs legacy Reflection.Emit PowerShell 5.1.", + "experiments": { + "cli-small.json": { + "note": "CLI child process wall time; fixture setup, init, independent PNG verification and cleanup excluded. Equal growing histories; AB/BA ordering; no input injected.", + "summary": { + "rounds": 20, + "region": { + "x": 49, + "y": 78, + "width": 400, + "height": 300 + }, + "candidateMedianMs": 634.5010999999995, + "candidateMinMs": 450.4938000000002, + "candidateMaxMs": 800.8502999999982, + "baselineMedianMs": 1097.004499999999, + "pairedMedianSavedMs": 479.7618000000002, + "pairsWon": 20, + "reduction": 0.4216057454641252 + }, + "samples": [ + { + "pair": 0, + "variant": "baseline", + "totalMs": 1050.8962, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 0, + "variant": "candidate", + "totalMs": 450.4938000000002, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 1, + "variant": "candidate", + "totalMs": 457.12829999999985, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 1, + "variant": "baseline", + "totalMs": 951.6668, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 2, + "variant": "baseline", + "totalMs": 1002.815, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 2, + "variant": "candidate", + "totalMs": 491.97440000000006, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 3, + "variant": "candidate", + "totalMs": 539.4537, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 3, + "variant": "baseline", + "totalMs": 1013.8636000000006, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 4, + "variant": "baseline", + "totalMs": 1049.1443999999992, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 4, + "variant": "candidate", + "totalMs": 561.1220000000012, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 5, + "variant": "candidate", + "totalMs": 555.293099999999, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 5, + "variant": "baseline", + "totalMs": 1031.4884999999995, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 6, + "variant": "baseline", + "totalMs": 1053.6647999999986, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 6, + "variant": "candidate", + "totalMs": 551.0487999999987, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 7, + "variant": "candidate", + "totalMs": 592.9195, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 7, + "variant": "baseline", + "totalMs": 1096.0334000000003, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 8, + "variant": "baseline", + "totalMs": 1091.1772, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 8, + "variant": "candidate", + "totalMs": 607.8490000000002, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 9, + "variant": "candidate", + "totalMs": 626.4748, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 9, + "variant": "baseline", + "totalMs": 1072.1526999999987, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 10, + "variant": "baseline", + "totalMs": 1097.975599999998, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 10, + "variant": "candidate", + "totalMs": 664.2993000000024, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 11, + "variant": "candidate", + "totalMs": 642.527399999999, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 11, + "variant": "baseline", + "totalMs": 1127.7547999999988, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 12, + "variant": "baseline", + "totalMs": 1127.2885999999999, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 12, + "variant": "candidate", + "totalMs": 658.1382000000012, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 13, + "variant": "candidate", + "totalMs": 673.5034999999989, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 13, + "variant": "baseline", + "totalMs": 1132.4562000000005, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 14, + "variant": "baseline", + "totalMs": 1145.4271000000008, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 14, + "variant": "candidate", + "totalMs": 672.0434999999998, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 15, + "variant": "candidate", + "totalMs": 711.1033000000025, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 15, + "variant": "baseline", + "totalMs": 1219.4012000000002, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 16, + "variant": "baseline", + "totalMs": 1243.4700999999986, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 16, + "variant": "candidate", + "totalMs": 740.5472999999984, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 17, + "variant": "candidate", + "totalMs": 755.7019, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 17, + "variant": "baseline", + "totalMs": 1219.2816999999995, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 18, + "variant": "baseline", + "totalMs": 1244.5004999999983, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 18, + "variant": "candidate", + "totalMs": 800.8502999999982, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 19, + "variant": "candidate", + "totalMs": 798.7922000000035, + "imageBytes": 2175, + "pixelsVerified": true + }, + { + "pair": 19, + "variant": "baseline", + "totalMs": 1235.9090999999971, + "imageBytes": 2175, + "pixelsVerified": true + } + ] + }, + "final-small.json": { + "note": "Complete CLI wall time. Fixture/init/pixel checks excluded. Rotating then reversed order. Fresh mode uses a new initialized workspace for every sample, records failures and continues the finite schedule without retry; growing-history mode stops on failure.", + "fresh": true, + "rounds": 20, + "names": [ + "ps51", + "native" + ], + "samples": [ + { + "pair": 0, + "name": "ps51", + "totalMs": 1008.0616000000001, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 0, + "name": "native", + "totalMs": 468.6709999999998, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 1, + "name": "native", + "totalMs": 509.31690000000026, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 1, + "name": "ps51", + "totalMs": 996.6217999999999, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 2, + "name": "native", + "totalMs": 495.01039999999966, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 2, + "name": "ps51", + "totalMs": 1011.7428, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 3, + "name": "ps51", + "totalMs": 1017.1054000000004, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 3, + "name": "native", + "totalMs": 478.27999999999975, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 4, + "name": "ps51", + "totalMs": 980.9737999999998, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 4, + "name": "native", + "totalMs": 489.48309999999947, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 5, + "name": "native", + "totalMs": 489.1402999999991, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 5, + "name": "ps51", + "totalMs": 988.5144999999993, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 6, + "name": "native", + "totalMs": 495.01860000000124, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 6, + "name": "ps51", + "totalMs": 946.2088000000003, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 7, + "name": "ps51", + "totalMs": 940.7579000000005, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 7, + "name": "native", + "totalMs": 489.09369999999944, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 8, + "name": "ps51", + "totalMs": 960.3341, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 8, + "name": "native", + "totalMs": 480.7548000000006, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 9, + "name": "native", + "totalMs": 502.8723000000009, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 9, + "name": "ps51", + "totalMs": 950.4380000000001, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 10, + "name": "native", + "totalMs": 478.2536999999993, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 10, + "name": "ps51", + "totalMs": 957.3345999999983, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 11, + "name": "ps51", + "totalMs": 940.8670999999995, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 11, + "name": "native", + "totalMs": 455.1689000000006, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 12, + "name": "ps51", + "totalMs": 951.2452999999987, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 12, + "name": "native", + "totalMs": 474.51590000000215, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 13, + "name": "native", + "totalMs": 482.4260000000031, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 13, + "name": "ps51", + "totalMs": 951.1913000000022, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 14, + "name": "native", + "totalMs": 455.0486000000019, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 14, + "name": "ps51", + "totalMs": 949.2805000000008, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 15, + "name": "ps51", + "totalMs": 1014.8942999999999, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 15, + "name": "native", + "totalMs": 494.0685000000012, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 16, + "name": "ps51", + "totalMs": 997.2609999999986, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 16, + "name": "native", + "totalMs": 518.2692999999999, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 17, + "name": "native", + "totalMs": 509.15940000000046, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 17, + "name": "ps51", + "totalMs": 978.637700000003, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 18, + "name": "native", + "totalMs": 478.9346000000005, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 18, + "name": "ps51", + "totalMs": 970.1674000000021, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 19, + "name": "ps51", + "totalMs": 952.709899999998, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + }, + { + "pair": 19, + "name": "native", + "totalMs": 477.0926000000036, + "status": 0, + "imageBytes": 2151, + "pixelsVerified": true + } + ], + "region": { + "x": 49, + "y": 78, + "width": 400, + "height": 300 + }, + "medians": { + "ps51": 965.2507500000011, + "native": 485.7598500000013 + }, + "failures": { + "ps51": 0, + "native": 0 + }, + "comparisons": [ + { + "baseline": "ps51", + "candidate": "native", + "matchedPairs": 20, + "pairedMedianSavedMs": 482.63874999999916, + "pairsWon": 20, + "medianReduction": 0.49675268317584753 + } + ], + "complete": true + }, + "final-large.json": { + "note": "Complete CLI wall time. Fixture/init/pixel checks excluded. Rotating then reversed order. Fresh mode uses a new initialized workspace for every sample, records failures and continues the finite schedule without retry; growing-history mode stops on failure.", + "fresh": false, + "rounds": 12, + "names": [ + "ps51", + "native" + ], + "samples": [ + { + "pair": 0, + "name": "ps51", + "totalMs": 1046.9901, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 0, + "name": "native", + "totalMs": 515.0592000000001, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 1, + "name": "native", + "totalMs": 542.4740999999999, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 1, + "name": "ps51", + "totalMs": 1033.8073, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 2, + "name": "native", + "totalMs": 588.2500999999997, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 2, + "name": "ps51", + "totalMs": 1063.7695999999996, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 3, + "name": "ps51", + "totalMs": 1078.4087, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 3, + "name": "native", + "totalMs": 622.2636000000002, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 4, + "name": "ps51", + "totalMs": 1150.4033000000009, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 4, + "name": "native", + "totalMs": 618.4577000000008, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 5, + "name": "native", + "totalMs": 679.247800000001, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 5, + "name": "ps51", + "totalMs": 1167.3279000000002, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 6, + "name": "native", + "totalMs": 690.3217999999997, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 6, + "name": "ps51", + "totalMs": 1194.689699999999, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 7, + "name": "ps51", + "totalMs": 1224.4148999999998, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 7, + "name": "native", + "totalMs": 750.2513999999992, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 8, + "name": "ps51", + "totalMs": 1253.309799999999, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 8, + "name": "native", + "totalMs": 872.2827999999972, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 9, + "name": "native", + "totalMs": 873.0690000000031, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 9, + "name": "ps51", + "totalMs": 1367.712599999999, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 10, + "name": "native", + "totalMs": 826.9248999999982, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 10, + "name": "ps51", + "totalMs": 1317.181199999999, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 11, + "name": "ps51", + "totalMs": 1313.0694000000003, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + }, + { + "pair": 11, + "name": "native", + "totalMs": 839.4686000000002, + "status": 0, + "imageBytes": 6726, + "pixelsVerified": true + } + ], + "region": { + "x": 49, + "y": 78, + "width": 1280, + "height": 720 + }, + "medians": { + "ps51": 1181.0087999999996, + "native": 684.7848000000004 + }, + "failures": { + "ps51": 0, + "native": 0 + }, + "comparisons": [ + { + "baseline": "ps51", + "candidate": "native", + "matchedPairs": 12, + "pairedMedianSavedMs": 489.16820000000007, + "pairsWon": 12, + "medianReduction": 0.4201696041553623 + } + ], + "complete": true + } + } +} diff --git a/docs/research/data/observe-powershell-20261109.json b/docs/research/data/observe-powershell-20261109.json new file mode 100644 index 0000000..6f2e5fb --- /dev/null +++ b/docs/research/data/observe-powershell-20261109.json @@ -0,0 +1,2139 @@ +{ + "date": "2026-11-09", + "conditions": { + "node": "24.15.0", + "pwsh": "7.6.9", + "coreRuntime": ".NET 10.0.14", + "stock": "5.1.26100.9711", + "region": "400x300", + "gameRunning": true, + "helperProtocolUnchanged": true + }, + "experiments": { + "runtime-cli.json": { + "note": "CLI child process wall time; fixture setup, init, independent PNG verification and cleanup excluded. Equal growing histories; AB/BA ordering; no input injected.", + "summary": { + "rounds": 12, + "region": { + "x": 49, + "y": 78, + "width": 400, + "height": 300 + }, + "candidateMedianMs": 1742.8421999999991, + "candidateMinMs": 1566.4042000000009, + "candidateMaxMs": 2192.3762000000006, + "baselineMedianMs": 1650.1657999999989, + "pairedMedianSavedMs": -110.09355000000141, + "pairsWon": 2, + "reduction": -0.056161871734343505 + }, + "samples": [ + { + "pair": 0, + "variant": "baseline", + "totalMs": 1637.3953999999999, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 0, + "variant": "candidate", + "totalMs": 1624.3202000000006, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 1, + "variant": "candidate", + "totalMs": 1852.6908999999996, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 1, + "variant": "baseline", + "totalMs": 1593.1417000000001, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 2, + "variant": "baseline", + "totalMs": 1502.6961999999994, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 2, + "variant": "candidate", + "totalMs": 1629.4650000000001, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 3, + "variant": "candidate", + "totalMs": 1566.4042000000009, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 3, + "variant": "baseline", + "totalMs": 1678.7849000000006, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 4, + "variant": "baseline", + "totalMs": 1794.4009999999998, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 4, + "variant": "candidate", + "totalMs": 2192.3762000000006, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 5, + "variant": "candidate", + "totalMs": 2025.5805, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 5, + "variant": "baseline", + "totalMs": 1650.9377999999997, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 6, + "variant": "baseline", + "totalMs": 1613.0365999999995, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 6, + "variant": "candidate", + "totalMs": 1698.2063999999991, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 7, + "variant": "candidate", + "totalMs": 1682.6569999999992, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 7, + "variant": "baseline", + "totalMs": 1608.138799999997, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 8, + "variant": "baseline", + "totalMs": 1676.1238999999987, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 8, + "variant": "candidate", + "totalMs": 1779.5155000000013, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 9, + "variant": "candidate", + "totalMs": 1707.7727999999988, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 9, + "variant": "baseline", + "totalMs": 1649.393799999998, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 10, + "variant": "baseline", + "totalMs": 1677.6420999999973, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 10, + "variant": "candidate", + "totalMs": 1812.7632000000012, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 11, + "variant": "candidate", + "totalMs": 1777.9115999999995, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 11, + "variant": "baseline", + "totalMs": 1661.1160999999993, + "imageBytes": 2168, + "pixelsVerified": true + } + ] + }, + "ps7-load-cli.json": { + "note": "CLI child process wall time; fixture setup, init, independent PNG verification and cleanup excluded. Equal growing histories; AB/BA ordering; no input injected.", + "summary": { + "rounds": 12, + "region": { + "x": 49, + "y": 78, + "width": 400, + "height": 300 + }, + "candidateMedianMs": 1753.6211500000006, + "candidateMinMs": 1584.445600000001, + "candidateMaxMs": 2115.3966, + "baselineMedianMs": 1761.5597999999982, + "pairedMedianSavedMs": 29.002849999997125, + "pairsWon": 6, + "reduction": 0.004506602614340771 + }, + "samples": [ + { + "pair": 0, + "variant": "baseline", + "totalMs": 2147.3898, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 0, + "variant": "candidate", + "totalMs": 1750.6282999999999, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 1, + "variant": "candidate", + "totalMs": 1689.0509000000002, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 1, + "variant": "baseline", + "totalMs": 1636.9727000000003, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 2, + "variant": "baseline", + "totalMs": 1733.467999999999, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 2, + "variant": "candidate", + "totalMs": 1596.0246000000006, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 3, + "variant": "candidate", + "totalMs": 1584.445600000001, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 3, + "variant": "baseline", + "totalMs": 1652.1777999999995, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 4, + "variant": "baseline", + "totalMs": 1631.820099999999, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 4, + "variant": "candidate", + "totalMs": 1756.6140000000014, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 5, + "variant": "candidate", + "totalMs": 1714.629499999999, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 5, + "variant": "baseline", + "totalMs": 1692.1359999999986, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 6, + "variant": "baseline", + "totalMs": 1674.3503999999994, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 6, + "variant": "candidate", + "totalMs": 1728.291000000001, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 7, + "variant": "candidate", + "totalMs": 1813.9071000000004, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 7, + "variant": "baseline", + "totalMs": 1945.2069999999985, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 8, + "variant": "baseline", + "totalMs": 2294.2936999999984, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 8, + "variant": "candidate", + "totalMs": 2115.3966, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 9, + "variant": "candidate", + "totalMs": 1956.5251000000062, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 9, + "variant": "baseline", + "totalMs": 1901.9075999999986, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 10, + "variant": "baseline", + "totalMs": 1789.6515999999974, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 10, + "variant": "candidate", + "totalMs": 1799.3781000000017, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 11, + "variant": "candidate", + "totalMs": 1766.1781000000046, + "imageBytes": 2168, + "pixelsVerified": true + }, + { + "pair": 11, + "variant": "baseline", + "totalMs": 2011.3085999999967, + "imageBytes": 2168, + "pixelsVerified": true + } + ] + }, + "final-fresh-matrix.json": { + "note": "Complete CLI wall time. Fixture/init/pixel checks excluded. Rotating then reversed order. Fresh mode uses a new initialized workspace for every sample, records failures and continues the finite schedule without retry; growing-history mode stops on failure.", + "fresh": true, + "rounds": 20, + "names": [ + "ps51-current", + "ps7-portable", + "ps7-dll", + "ps7-dll-load-native", + "ps51-dll-load-native" + ], + "samples": [ + { + "pair": 0, + "name": "ps51-current", + "totalMs": 1046.5522, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 0, + "name": "ps7-portable", + "totalMs": 1052.4125, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 0, + "name": "ps7-dll", + "totalMs": 967.8904000000002, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 0, + "name": "ps7-dll-load-native", + "totalMs": 1010.0720999999999, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 0, + "name": "ps51-dll-load-native", + "totalMs": 903.9772000000003, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 1, + "name": "ps7-portable", + "totalMs": 1035.0147000000006, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 1, + "name": "ps7-dll", + "totalMs": 986.991, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 1, + "name": "ps7-dll-load-native", + "totalMs": 1015.3782000000001, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 1, + "name": "ps51-dll-load-native", + "totalMs": 916.937100000001, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 1, + "name": "ps51-current", + "totalMs": 940.4871000000003, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 2, + "name": "ps7-dll", + "totalMs": 1011.2037999999993, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 2, + "name": "ps7-dll-load-native", + "totalMs": 1004.6682000000001, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 2, + "name": "ps51-dll-load-native", + "totalMs": 924.7963999999993, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 2, + "name": "ps51-current", + "totalMs": 943.5378000000001, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 2, + "name": "ps7-portable", + "totalMs": 1007.9500000000007, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 3, + "name": "ps7-dll-load-native", + "totalMs": 966.7709999999988, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 3, + "name": "ps51-dll-load-native", + "totalMs": 942.582400000003, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 3, + "name": "ps51-current", + "totalMs": 946.5083000000013, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 3, + "name": "ps7-portable", + "totalMs": 1024.0099999999984, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 3, + "name": "ps7-dll", + "totalMs": 1035.6679000000004, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 4, + "name": "ps51-dll-load-native", + "totalMs": 920.4357000000018, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 4, + "name": "ps51-current", + "totalMs": 967.4998000000014, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 4, + "name": "ps7-portable", + "totalMs": 1045.7610999999997, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 4, + "name": "ps7-dll", + "totalMs": 975.354800000001, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 4, + "name": "ps7-dll-load-native", + "totalMs": 1011.1539999999986, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 5, + "name": "ps51-dll-load-native", + "totalMs": 937.8051000000014, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 5, + "name": "ps7-dll-load-native", + "totalMs": 1027.3044999999984, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 5, + "name": "ps7-dll", + "totalMs": 1018.6768999999986, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 5, + "name": "ps7-portable", + "totalMs": 1059.2956999999988, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 5, + "name": "ps51-current", + "totalMs": 1002.8746000000028, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 6, + "name": "ps51-current", + "totalMs": 989.202699999998, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 6, + "name": "ps51-dll-load-native", + "totalMs": 943.7183999999979, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 6, + "name": "ps7-dll-load-native", + "totalMs": 970.5559999999969, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 6, + "name": "ps7-dll", + "totalMs": 1013.5826000000015, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 6, + "name": "ps7-portable", + "totalMs": 1079.3332999999984, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 7, + "name": "ps7-portable", + "totalMs": 1010.6099000000031, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 7, + "name": "ps51-current", + "totalMs": 943.7368999999962, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 7, + "name": "ps51-dll-load-native", + "totalMs": 945.2650000000067, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 7, + "name": "ps7-dll-load-native", + "totalMs": 956.9170000000013, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 7, + "name": "ps7-dll", + "totalMs": 1020.2512999999963, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 8, + "name": "ps7-dll", + "totalMs": 1018.2253999999957, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 8, + "name": "ps7-portable", + "totalMs": 1040.012999999999, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 8, + "name": "ps51-current", + "totalMs": 948.8810999999987, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 8, + "name": "ps51-dll-load-native", + "totalMs": 918.9311000000016, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 8, + "name": "ps7-dll-load-native", + "totalMs": 950.6301000000021, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 9, + "name": "ps7-dll-load-native", + "totalMs": 1027.486100000002, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 9, + "name": "ps7-dll", + "totalMs": 1021.1343000000052, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 9, + "name": "ps7-portable", + "totalMs": 1029.6935000000012, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 9, + "name": "ps51-current", + "totalMs": 955.0138000000006, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 9, + "name": "ps51-dll-load-native", + "totalMs": 939.2188999999998, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 10, + "name": "ps51-current", + "totalMs": 945.3205999999991, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 10, + "name": "ps7-portable", + "totalMs": 975.904300000002, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 10, + "name": "ps7-dll", + "totalMs": 948.2316999999966, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 10, + "name": "ps7-dll-load-native", + "totalMs": 1018.3480999999956, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 10, + "name": "ps51-dll-load-native", + "totalMs": 916.5535000000018, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 11, + "name": "ps7-portable", + "totalMs": 1027.8575000000055, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 11, + "name": "ps7-dll", + "totalMs": 965.0241000000024, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 11, + "name": "ps7-dll-load-native", + "totalMs": 1012.447699999997, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 11, + "name": "ps51-dll-load-native", + "totalMs": 941.6624000000011, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 11, + "name": "ps51-current", + "totalMs": 958.3879000000015, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 12, + "name": "ps7-dll", + "totalMs": 1017.9833999999973, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 12, + "name": "ps7-dll-load-native", + "totalMs": 1022.3620999999985, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 12, + "name": "ps51-dll-load-native", + "totalMs": 938.1107999999949, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 12, + "name": "ps51-current", + "totalMs": 941.0277999999962, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 12, + "name": "ps7-portable", + "totalMs": 1024.3182000000015, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 13, + "name": "ps7-dll-load-native", + "totalMs": 953.0978000000032, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 13, + "name": "ps51-dll-load-native", + "totalMs": 923.3213000000105, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 13, + "name": "ps51-current", + "totalMs": 962.9323000000004, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 13, + "name": "ps7-portable", + "totalMs": 1058.5678999999946, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 13, + "name": "ps7-dll", + "totalMs": 973.3887000000104, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 14, + "name": "ps51-dll-load-native", + "totalMs": 923.4328999999998, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 14, + "name": "ps51-current", + "totalMs": 973.755600000004, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 14, + "name": "ps7-portable", + "totalMs": 1068.4334999999992, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 14, + "name": "ps7-dll", + "totalMs": 972.472099999999, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 14, + "name": "ps7-dll-load-native", + "totalMs": 1012.7918999999965, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 15, + "name": "ps51-dll-load-native", + "totalMs": 918.1851000000024, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 15, + "name": "ps7-dll-load-native", + "totalMs": 998.5339000000095, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 15, + "name": "ps7-dll", + "totalMs": 1038.0089000000007, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 15, + "name": "ps7-portable", + "totalMs": 1060.7926999999909, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 15, + "name": "ps51-current", + "totalMs": 989.4297999999981, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 16, + "name": "ps51-current", + "totalMs": 963.1500999999989, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 16, + "name": "ps51-dll-load-native", + "totalMs": 959.4480999999942, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 16, + "name": "ps7-dll-load-native", + "totalMs": 1007.6137000000017, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 16, + "name": "ps7-dll", + "totalMs": 1049.2593999999954, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 16, + "name": "ps7-portable", + "totalMs": 1062.9623999999894, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 17, + "name": "ps7-portable", + "totalMs": 1001.5418000000063, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 17, + "name": "ps51-current", + "totalMs": 981.055400000012, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 17, + "name": "ps51-dll-load-native", + "totalMs": 930.6694999999891, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 17, + "name": "ps7-dll-load-native", + "totalMs": 1007.5179000000062, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 17, + "name": "ps7-dll", + "totalMs": 1005.7292999999918, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 18, + "name": "ps7-dll", + "totalMs": 1003.2740999999951, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 18, + "name": "ps7-portable", + "totalMs": 1034.8650000000052, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 18, + "name": "ps51-current", + "totalMs": 950.511599999998, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 18, + "name": "ps51-dll-load-native", + "totalMs": 949.9475000000093, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 18, + "name": "ps7-dll-load-native", + "totalMs": 973.5977999999886, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 19, + "name": "ps7-dll-load-native", + "totalMs": 1014.4192000000039, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 19, + "name": "ps7-dll", + "totalMs": 1001.8784000000014, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 19, + "name": "ps7-portable", + "totalMs": 1038.6964000000007, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 19, + "name": "ps51-current", + "totalMs": 952.3892999999953, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + }, + { + "pair": 19, + "name": "ps51-dll-load-native", + "totalMs": 926.7143999999971, + "status": 0, + "imageBytes": 2173, + "pixelsVerified": true + } + ], + "region": { + "x": 49, + "y": 78, + "width": 400, + "height": 300 + }, + "medians": { + "ps51-current": 956.7008500000011, + "ps7-portable": 1036.8555500000007, + "ps7-dll": 1008.4665499999956, + "ps7-dll-load-native": 1008.8429000000008, + "ps51-dll-load-native": 928.6919499999931 + }, + "failures": { + "ps51-current": 0, + "ps7-portable": 0, + "ps7-dll": 0, + "ps7-dll-load-native": 0, + "ps51-dll-load-native": 0 + }, + "comparisons": [ + { + "baseline": "ps51-current", + "candidate": "ps7-portable", + "matchedPairs": 20, + "pairedMedianSavedMs": -77.88149999999769, + "pairsWon": 0, + "medianReduction": -0.0837824070084181 + }, + { + "baseline": "ps51-current", + "candidate": "ps7-dll", + "matchedPairs": 20, + "pairedMedianSavedMs": -47.54150000000118, + "pairsWon": 2, + "medianReduction": -0.054108554413842436 + }, + { + "baseline": "ps51-current", + "candidate": "ps7-dll-load-native", + "matchedPairs": 20, + "pairedMedianSavedMs": -32.74939999999333, + "pairsWon": 3, + "medianReduction": -0.05450193757013966 + }, + { + "baseline": "ps51-current", + "candidate": "ps51-dll-load-native", + "matchedPairs": 20, + "pairedMedianSavedMs": 27.22099999999773, + "pairsWon": 19, + "medianReduction": 0.02927654971771787 + }, + { + "baseline": "ps7-portable", + "candidate": "ps7-dll", + "matchedPairs": 20, + "pairedMedianSavedMs": 29.63175000000774, + "pairsWon": 16, + "medianReduction": 0.027379898771825117 + }, + { + "baseline": "ps7-portable", + "candidate": "ps7-dll-load-native", + "matchedPairs": 20, + "pairedMedianSavedMs": 38.473750000000564, + "pairsWon": 18, + "medianReduction": 0.02701692632112529 + }, + { + "baseline": "ps7-portable", + "candidate": "ps51-dll-load-native", + "matchedPairs": 20, + "pairedMedianSavedMs": 107.74814999999944, + "pairsWon": 20, + "medianReduction": 0.10431887064693579 + }, + { + "baseline": "ps7-dll", + "candidate": "ps7-dll-load-native", + "matchedPairs": 20, + "pairedMedianSavedMs": -3.083650000007765, + "pairsWon": 9, + "medianReduction": -0.0003731903651194024 + }, + { + "baseline": "ps7-dll", + "candidate": "ps51-dll-load-native", + "matchedPairs": 20, + "pairedMedianSavedMs": 75.02304999999615, + "pairsWon": 20, + "medianReduction": 0.0791048547916664 + }, + { + "baseline": "ps7-dll-load-native", + "candidate": "ps51-dll-load-native", + "matchedPairs": 20, + "pairedMedianSavedMs": 80.11030000000392, + "pairsWon": 20, + "medianReduction": 0.0794483957809562 + } + ], + "complete": true + }, + "ps51-dll-fresh-matrix.json": { + "note": "Complete CLI wall time. Fixture/init/pixel checks excluded. Rotating then reversed order. Fresh mode uses a new initialized workspace for every sample, records failures and continues the finite schedule without retry; growing-history mode stops on failure.", + "fresh": true, + "rounds": 20, + "names": [ + "ps51-current", + "ps51-dll", + "ps51-dll-load-native" + ], + "samples": [ + { + "pair": 0, + "name": "ps51-current", + "totalMs": 1056.1922, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 0, + "name": "ps51-dll", + "totalMs": 939.8139000000001, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 0, + "name": "ps51-dll-load-native", + "totalMs": 1027.4861999999998, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 1, + "name": "ps51-dll", + "totalMs": 973.6432999999997, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 1, + "name": "ps51-dll-load-native", + "totalMs": 909.3524000000007, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 1, + "name": "ps51-current", + "totalMs": 952.0236000000004, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 2, + "name": "ps51-dll-load-native", + "totalMs": 914.7133000000003, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 2, + "name": "ps51-current", + "totalMs": 950.2282999999998, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 2, + "name": "ps51-dll", + "totalMs": 947.9606000000003, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 3, + "name": "ps51-dll-load-native", + "totalMs": 913.4260000000013, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 3, + "name": "ps51-dll", + "totalMs": 943.981600000001, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 3, + "name": "ps51-current", + "totalMs": 959.4068000000007, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 4, + "name": "ps51-current", + "totalMs": 927.9098999999987, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 4, + "name": "ps51-dll-load-native", + "totalMs": 917.5491000000002, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 4, + "name": "ps51-dll", + "totalMs": 929.5725999999995, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 5, + "name": "ps51-dll", + "totalMs": 905.6728999999996, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 5, + "name": "ps51-current", + "totalMs": 952.2258000000002, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 5, + "name": "ps51-dll-load-native", + "totalMs": 937.9012999999977, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 6, + "name": "ps51-current", + "totalMs": 934.9386999999988, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 6, + "name": "ps51-dll", + "totalMs": 913.0184999999983, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 6, + "name": "ps51-dll-load-native", + "totalMs": 943.3489000000009, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 7, + "name": "ps51-dll", + "totalMs": 941.8706999999995, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 7, + "name": "ps51-dll-load-native", + "totalMs": 905.0490000000027, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 7, + "name": "ps51-current", + "totalMs": 939.7343000000001, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 8, + "name": "ps51-dll-load-native", + "totalMs": 909.5178000000014, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 8, + "name": "ps51-current", + "totalMs": 931.1839, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 8, + "name": "ps51-dll", + "totalMs": 897.3567000000003, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 9, + "name": "ps51-dll-load-native", + "totalMs": 907.7981, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 9, + "name": "ps51-dll", + "totalMs": 936.5390000000007, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 9, + "name": "ps51-current", + "totalMs": 940.7380999999987, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 10, + "name": "ps51-current", + "totalMs": 937.1731, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 10, + "name": "ps51-dll-load-native", + "totalMs": 904.4634000000005, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 10, + "name": "ps51-dll", + "totalMs": 933.040399999998, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 11, + "name": "ps51-dll", + "totalMs": 935.3823999999986, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 11, + "name": "ps51-current", + "totalMs": 946.4683999999979, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 11, + "name": "ps51-dll-load-native", + "totalMs": 946.3258999999962, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 12, + "name": "ps51-current", + "totalMs": 960.9720000000016, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 12, + "name": "ps51-dll", + "totalMs": 937.6187999999966, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 12, + "name": "ps51-dll-load-native", + "totalMs": 935.8058999999994, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 13, + "name": "ps51-dll", + "totalMs": 946.9652999999962, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 13, + "name": "ps51-dll-load-native", + "totalMs": 937.7785999999978, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 13, + "name": "ps51-current", + "totalMs": 958.1574999999939, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 14, + "name": "ps51-dll-load-native", + "totalMs": 942.4571999999971, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 14, + "name": "ps51-current", + "totalMs": 941.5121999999974, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 14, + "name": "ps51-dll", + "totalMs": 946.5600999999951, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 15, + "name": "ps51-dll-load-native", + "totalMs": 943.7576999999947, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 15, + "name": "ps51-dll", + "totalMs": 954.6493000000046, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 15, + "name": "ps51-current", + "totalMs": 965.3130999999994, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 16, + "name": "ps51-current", + "totalMs": 958.5311999999976, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 16, + "name": "ps51-dll-load-native", + "totalMs": 950.850099999996, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 16, + "name": "ps51-dll", + "totalMs": 945.0316999999995, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 17, + "name": "ps51-dll", + "totalMs": 932.1214000000036, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 17, + "name": "ps51-current", + "totalMs": 966.1789999999964, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 17, + "name": "ps51-dll-load-native", + "totalMs": 952.4686000000002, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 18, + "name": "ps51-current", + "totalMs": 952.7826999999961, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 18, + "name": "ps51-dll", + "totalMs": 925.4013999999952, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 18, + "name": "ps51-dll-load-native", + "totalMs": 951.4279000000024, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 19, + "name": "ps51-dll", + "totalMs": 949.5264999999999, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 19, + "name": "ps51-dll-load-native", + "totalMs": 914.823000000004, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + }, + { + "pair": 19, + "name": "ps51-current", + "totalMs": 971.5207999999984, + "status": 0, + "imageBytes": 2166, + "pixelsVerified": true + } + ], + "region": { + "x": 49, + "y": 78, + "width": 400, + "height": 300 + }, + "medians": { + "ps51-current": 952.1247000000003, + "ps51-dll": 938.7163499999983, + "ps51-dll-load-native": 936.7922499999986 + }, + "failures": { + "ps51-current": 0, + "ps51-dll": 0, + "ps51-dll-load-native": 0 + }, + "comparisons": [ + { + "baseline": "ps51-current", + "candidate": "ps51-dll", + "matchedPairs": 20, + "pairedMedianSavedMs": 12.345849999997881, + "pairsWon": 16, + "medianReduction": 0.014082556623099873 + }, + { + "baseline": "ps51-current", + "candidate": "ps51-dll-load-native", + "matchedPairs": 20, + "pairedMedianSavedMs": 21.610750000001644, + "pairsWon": 18, + "medianReduction": 0.016103405362765666 + }, + { + "baseline": "ps51-dll", + "candidate": "ps51-dll-load-native", + "matchedPairs": 20, + "pairedMedianSavedMs": 6.644799999998213, + "pairsWon": 12, + "medianReduction": 0.002049713952462562 + } + ], + "complete": true + }, + "startup.json": { + "note": "Fresh process, warm OS caches, exit 0; game/background load retained.", + "summary": { + "ps51": 187.78035, + "ps7": 232.21714999999995 + }, + "samples": [ + { + "pair": 0, + "name": "ps51", + "totalMs": 210.2994 + }, + { + "pair": 0, + "name": "ps7", + "totalMs": 253.7116 + }, + { + "pair": 1, + "name": "ps7", + "totalMs": 234.92679999999996 + }, + { + "pair": 1, + "name": "ps51", + "totalMs": 208.86020000000008 + }, + { + "pair": 2, + "name": "ps51", + "totalMs": 204.3723000000001 + }, + { + "pair": 2, + "name": "ps7", + "totalMs": 218.93899999999985 + }, + { + "pair": 3, + "name": "ps7", + "totalMs": 230.07089999999994 + }, + { + "pair": 3, + "name": "ps51", + "totalMs": 181.67139999999995 + }, + { + "pair": 4, + "name": "ps51", + "totalMs": 185.26199999999994 + }, + { + "pair": 4, + "name": "ps7", + "totalMs": 229.41790000000015 + }, + { + "pair": 5, + "name": "ps7", + "totalMs": 224.07960000000003 + }, + { + "pair": 5, + "name": "ps51", + "totalMs": 180.9757999999997 + }, + { + "pair": 6, + "name": "ps51", + "totalMs": 183.91240000000016 + }, + { + "pair": 6, + "name": "ps7", + "totalMs": 225.98419999999987 + }, + { + "pair": 7, + "name": "ps7", + "totalMs": 227.41670000000022 + }, + { + "pair": 7, + "name": "ps51", + "totalMs": 187.9317000000001 + }, + { + "pair": 8, + "name": "ps51", + "totalMs": 183.32310000000007 + }, + { + "pair": 8, + "name": "ps7", + "totalMs": 231.80209999999988 + }, + { + "pair": 9, + "name": "ps7", + "totalMs": 229.4665 + }, + { + "pair": 9, + "name": "ps51", + "totalMs": 187.49159999999983 + }, + { + "pair": 10, + "name": "ps51", + "totalMs": 187.6289999999999 + }, + { + "pair": 10, + "name": "ps7", + "totalMs": 236.11419999999998 + }, + { + "pair": 11, + "name": "ps7", + "totalMs": 257.9993000000004 + }, + { + "pair": 11, + "name": "ps51", + "totalMs": 216.4306999999999 + }, + { + "pair": 12, + "name": "ps51", + "totalMs": 185.3069999999998 + }, + { + "pair": 12, + "name": "ps7", + "totalMs": 234.3191999999999 + }, + { + "pair": 13, + "name": "ps7", + "totalMs": 232.6322 + }, + { + "pair": 13, + "name": "ps51", + "totalMs": 200.03809999999976 + }, + { + "pair": 14, + "name": "ps51", + "totalMs": 191.9445999999998 + }, + { + "pair": 14, + "name": "ps7", + "totalMs": 232.67489999999998 + }, + { + "pair": 15, + "name": "ps7", + "totalMs": 233.40759999999955 + }, + { + "pair": 15, + "name": "ps51", + "totalMs": 188.46510000000035 + } + ] + }, + "runtime-dll-profile-summary.json": [ + { + "name": "ps51-static", + "helperMedianMs": 888.6360500000001, + "stages": { + "nativeReady": 74.41955, + "assembliesReady": 131.6031, + "requestReady": 276.67904999999996, + "preSnapshot": 402.5602, + "pixelsReady": 457.47700000000003, + "postSnapshot": 494.18025, + "ready": 510.54460000000006 + } + }, + { + "name": "ps7", + "helperMedianMs": 1070.0535500000005, + "stages": { + "nativeReady": 64.05709999999999, + "assembliesReady": 256.49955, + "requestReady": 339.6575, + "preSnapshot": 451.2694, + "pixelsReady": 498.82174999999995, + "postSnapshot": 540.93935, + "ready": 562.35095 + } + }, + { + "name": "ps51-static-dll", + "helperMedianMs": 888.8049999999994, + "stages": { + "nativeReady": 38.42515, + "assembliesReady": 101.32685000000001, + "requestReady": 248.52975, + "preSnapshot": 378.36655, + "pixelsReady": 432.55765, + "postSnapshot": 470.1496, + "ready": 486.40465 + } + }, + { + "name": "ps7-dll", + "helperMedianMs": 981.1275999999998, + "stages": { + "nativeReady": 12.98245, + "assembliesReady": 181.02960000000002, + "requestReady": 273.25415, + "preSnapshot": 367.57335, + "pixelsReady": 412.78085, + "postSnapshot": 447.62705, + "ready": 464.31910000000005 + } + } + ], + "load-profile-summary.json": [ + { + "name": "ps51-static", + "helperMedianMs": 815.6256999999991, + "stages": { + "nativeReady": 70.98985, + "assembliesReady": 123.22525, + "requestReady": 252.40705000000003, + "preSnapshot": 366.79805, + "pixelsReady": 415.82345000000004, + "postSnapshot": 447.59595, + "ready": 463.52095 + } + }, + { + "name": "ps7", + "helperMedianMs": 966.7256499999995, + "stages": { + "nativeReady": 57.3043, + "assembliesReady": 228.71179999999998, + "requestReady": 300.63245, + "preSnapshot": 394.67015000000004, + "pixelsReady": 437.3393, + "postSnapshot": 478.12795, + "ready": 497.38445 + } + }, + { + "name": "ps51-static-dll-load", + "helperMedianMs": 808.2284500000001, + "stages": { + "nativeReady": 32.954750000000004, + "assembliesReady": 49.79745, + "requestReady": 227.3163, + "preSnapshot": 346.6018, + "pixelsReady": 396.07050000000004, + "postSnapshot": 433.29815, + "ready": 448.78095 + } + }, + { + "name": "ps7-dll-load", + "helperMedianMs": 925.9945000000002, + "stages": { + "nativeReady": 12.008949999999999, + "assembliesReady": 23.4247, + "requestReady": 250.70615, + "preSnapshot": 334.404, + "pixelsReady": 377.92494999999997, + "postSnapshot": 418.15105, + "ready": 436.78634999999997 + } + } + ] + }, + "abortedRuns": [ + { + "name": "ps7-native-cli", + "successfulCaptures": 5, + "failedCaptures": 1, + "error": "capture_invalid", + "privateReason": "not retained", + "usedForPerformanceConclusion": false + }, + { + "name": "native-debug-cli", + "successfulCaptures": 22, + "failedCaptures": 1, + "error": "capture_invalid", + "privateReason": "environment_changed; changing field not retained", + "usedForPerformanceConclusion": false + } + ] +} diff --git a/docs/research/efficiency-and-pi-image-delivery.md b/docs/research/efficiency-and-pi-image-delivery.md new file mode 100644 index 0000000..9b98a50 --- /dev/null +++ b/docs/research/efficiency-and-pi-image-delivery.md @@ -0,0 +1,91 @@ +# cu 效率调研与本轮决定 + +日期:2026-11-09。cu 源码基线:`d1b04f0`;Pi:本机 1.4.0。 + +## 已确认的断点与决定 + +`observe` 返回 `imagePath`;`act` 遇到 checkpoint 时返回 +`checkpoint.imagePath`。普通 bash 结果只有文本,所以截图生成不意味着模型 +收到了图像输入。Pi codemode 可以在一次外层工具调用中串行完成 +`bash → 解析 receipt → read → image()`。本轮已通过真实受控窗口验证。 + +本轮采用现有 skill 指导这个组合,不增加 CLI 参数、Pi 扩展或 MCP 服务: + +- `view = "image"`:需要定位、理解界面、视觉验收时直接交付图片。 +- `view = "none"`:只返回采集结果,供归档或程序处理;不调用 `image()`。 +- checkpoint 复用已经捕获的图像,不因结果只有路径而再运行 `observe`。 +- 在下一步动作已经明确时,同一 codemode 调用完成写 action 文件、执行和 + checkpoint 交付。模型需要新图作决策时,仍要进入下一轮模型推理。 + +`view` 只是 skill 示例中的变量,现有 CLI 不接受这个 flag。主规则放在 +skill description 和正文开头;具体实现见 +[Pi codemode recipes](../../skills/cu-automation/references/pi-codemode.md)。 + +## 本机测量 + +使用仓库的受控窗口 fixture,捕获其 400×300 内容区,没有向应用注入输入。 +以 fixture 随机 token 导出的颜色核对 PNG 像素,避免只凭文件存在判定成功。 +所有工作区均在系统临时目录,未创建仓库内 `.cu/`。 + +| 测量 | 样本 | 结果 | 解释范围 | +| --- | --- | --- | --- | +| CLI `observe` 总时长 | 连续 5 次 | 4.13、4.35、4.60、4.72、5.18 秒,排序后中位数 4.60 秒 | 此机器、小图、当前实现;不能外推完整任务耗时 | +| 已生成 PNG 的文件读取 | 同 5 次 | 0.40–2.32 毫秒 | 不包含模型视觉编码或推理成本 | +| 进程内 `observeRegion` 总时长 | 另外 3 次 | 4.01–4.43 秒 | 排除 CLI Node 启动 | +| 其中 Windows helper | 同 3 次 | 2.22–2.54 秒,约 55–57% | 包含 PowerShell 启动、Add-Type、捕获、结果序列化,未进一步分项 | +| helper 之外 | 同 3 次 | 1.80–1.89 秒 | 尚未拆分验证、文件系统与发布事务等阶段 | + +另做一次实际 codemode 调用,在同一结果中返回 receipt 和 PNG image block; +模型收到的图像是受控窗口的四色图案。此次 `observe` 约 4.34 秒,外层约 +9.7 秒包含 fixture 创建/关闭等实验开销,不能当作生产快捷路径耗时。 + +这些结果证明应先节省模型往返和不必要的重复采集。不能由小图读取时间推出 +图像 token 成本,也不能认定 helper 启动是全部瓶颈。尚无端到端任务成功率、 +费用或 p95 提速结论。 + +## 外部资料与可迁移做法 + +资料均于调研日期获取。项目主分支会变化,以下为当时的公开内容。 + +| 来源 | 直接看到的机制 | cu 的对应改进 | +| --- | --- | --- | +| [OpenCode Browse 产品页](https://opencode.ai/product/browse) 与 [仓库](https://github.com/anomalyco/browse) | 复用已有登录和标签页,后台工作、持久会话、execute、截图/录像/HAR | 减少重复初始化和状态重建;保持工作区/run 稳定;归档不强制送入上下文 | +| [Browse 官方 skill](https://github.com/anomalyco/browse/blob/main/cli/skills/browse/SKILL.md) | 紧凑 snapshot、find/diff、视觉 labels、screenshotDiff;依赖临时 UI 的动作留在同次 execute;视觉证据需要返回截图 buffer | 把采集与图像交付组合;复用 checkpoint;未来考虑局部/差异视图,但必须保存坐标映射 | +| [Vercel agent-browser](https://github.com/vercel-labs/agent-browser) | 持久浏览器、紧凑 snapshot 与元素 ref;DOM 变化后重新观察 | 若增加 UIA/浏览器语义通道,应绑定快照有效性,不能沿用过期 ref | +| [Microsoft Playwright CLI](https://github.com/microsoft/playwright-cli) | 按需 page data、局部 snapshot、深度限制、find、命令后状态产物 | 以决策需要选择信息范围;大产物存文件,按需读 | +| [Browser Use agent 源码](https://github.com/browser-use/browser-use/blob/main/browser_use/agent/service.py) | `use_vision` 支持 true/false/auto;源码当时仍采集截图用于云端同步,模型视觉输入另行控制;有每步动作数限制 | “采集”和“模型看见”分离;不要把 vision=false 当作未采集,也不要把浏览器的批量动作规则直接移植到 cu | + +Browse 的条件等待和多步执行基于浏览器语义与定位器。cu 当前是图像坐标输入, +D2 边界是现有执行合同;本轮只合并工具编排,不放宽第二个坐标动作、chord、 +焦点键的 checkpoint,也不自动续跑被截断的动作尾部。 + +## 流媒体调研的边界 + +Google 视频检索找到下列候选,但 YouTube 页面触发通知权限提示,ego-browser +把该 TaskSpace 交给用户。没有用户确认前,未继续操作该浏览器,也未读取 +视频字幕或完整观看。**本报告不把搜索摘要或视频标题当作已验证结论。** + +- [Token-Efficient Browser Automation for AI Agents — Alex Hitt](https://www.youtube.com/watch?v=7pJTsmZqEv0) +- [Browser Use with Managed Deep Agents — LangChain](https://www.youtube.com/watch?v=r1iJzoxFBtg) +- [Browser Agents Don't Need Better Models… — AI Engineer](https://www.youtube.com/watch?v=JnubYCYunk8) + +后续需要从视频字幕或实际演示抽取具体机制,再与官方实现核对。视频里的 +宣传提速数字不能直接作为 cu 的预期收益。 + +## 后续优化顺序及验收 + +1. **先验证 skill 是否改变模型行为。** 用用户自己的真实任务,比对原 skill + 与新 skill:任务成功率、模型决策轮数、重复 capture 次数、实际附图次数、 + 总耗时、可获得的模型 usage。不以“工具调用更少”代替任务成功。 +2. **给 capture 路径分阶段计时。** 分清 helper 启动/编译、屏幕读取、PNG、 + 验证、事务发布的占比,再决定是否引入预编译 helper;不能仅凭整体耗时 + 直接改成常驻 daemon,命令级资源生命周期仍需保留或单独决策。 +3. **按需视图与等待。** 可以研究较小观察区域、保持比例的预览与变化检测; + 裁剪需显式映射回原 observation。稳定像素不证明页面业务完成,条件等待 + 需有超时和任务对应的判定条件。 +4. **最后评估语义通道。** 浏览器 DOM 或 Windows UIA 可能省去视觉定位,但 + 应作为有单独证据合同的能力;不能将未验证的控件信息假设为现有 cu 功能。 + +本轮只有 skill、引用与调研文档变更。没有新增 CLI flag,也没有对生产代码 +或执行策略作改动。构建及受控 observe/图片交付链路已验证;checkpoint 交付 +的字段来自源码核对,本轮没有额外发送真实输入来跑该动作分支。 diff --git a/docs/research/observe-latency-hillclimb.md b/docs/research/observe-latency-hillclimb.md new file mode 100644 index 0000000..1081779 --- /dev/null +++ b/docs/research/observe-latency-hillclimb.md @@ -0,0 +1,173 @@ +# Observe 时间效率 Hill Climb + +## 结论与范围 + +2026-11-09,按“定位热点 → 小改动 → 交错对照 → 保留或丢弃”优化 Windows +`observe`。本轮保留一项改动:capture helper 不再逐次调用 C# 编译器,而在 +当前 PowerShell 5.1 的 CLR 中用 Reflection.Emit 生成等价 P/Invoke 方法。 + +完整 CLI 的最终对照结果约省 **155–160 毫秒/次**,总体中位数降幅约 **9%**。 +没有减少桌面状态检查、文件系统身份检查、PNG 验证或事务发布步骤;没有新增 +DLL、原生 addon、常驻进程、跨命令缓存或额外安装要求。input helper 未改。 + +这是本机受控窗口结果,不是所有机器、应用或图片内容的性能保证。 +本轮不是全桌面、多屏或锁屏环境的新增验收。 + +## 测量合同 + +- 主测量区间是 CLI 子进程启动到退出;包括 Node 启动、helper、文件校验、 + 归档发布与命令清理,不包括 fixture 启动、workspace init 和独立像素复验。 +- 补充的模块级测量在同一 Node 进程中调用 observe;它不包含逐次 Node/CLI + 冷启动,不能与 CLI 数字混用。 +- 开启两个仓库自有的 WinForms target/decoy;只截图 target 的客户区。 + 像素颜色由新 fixture token 派生,每次截图均用独立 PNG 解码器核对四个采样点。 +- baseline/candidate 使用独立 workspace,每对测试历史数量一致,交替 AB/BA。 + 历史逐次保留,不通过清空归档制造“更快”的结果。 +- 桌面任务串行执行,避免其他测试的输入或窗口影响。性能对照不与完整回归并跑。 +- 同时报告总体中位数、配对耗时差中位数和胜出对数,不只挑最快一次。 +- 四色 fixture 的 PNG 压缩率很高。大图测试扩大的是受控像素区域,不代表照片、 + 视频或复杂 UI 的内容分布。 + +环境:Node `v24.15.0`;stock Windows PowerShell `5.1.26100.9711`; +CLR `4.0.30319.42000`。Pi 的工具 shell 是 PowerShell 7;capture helper 仍是 5.1。 + +此前记录的小图 observe 为约 4.1–5.2 秒。本轮初始未修改代码时已经只有约 +1.2–1.4 秒,不能把这个环境/测量时点差异归因于本轮代码。 + +## 原始分项定位 + +开发用脚本对原始 helper 加累计时间标记,并包装父进程同步 fs 调用。 +这类插桩有额外开销,只用于热点定位,不用于最终性能胜负。 + +原始 400×300 捕获的一个样本: + +| 项目 | 时间或数量 | +| --- | ---: | +| 模块级总耗时 | 1,264 ms | +| helper 子进程总耗时 | 866 ms | +| C# 编译阶段 | 224 ms | +| pre-snapshot 后到像素就绪 | 43 ms | +| 像素就绪后到 PNG flush | 16 ms | +| 父进程 `realpath.native` | 1,435 次 / 233 ms | +| 父进程 `lstatSync` | 1,544 次 / 25 ms | + +helper 内部累计 ready 时间约 533 ms;子进程总耗时与其差值还包含启动及收尾, +不是可以直接删掉的单一阶段。父进程包含多个边界的重复读取与归档检查,调用 +数量随 retained history 增加;因此一次 observe 的成本不只是生成一张 PNG。 + +## 候选与取舍 + +### 1. 减少 Add-Type 编译引用:未保留 + +在临时构建副本中尝试缩小 C# 引用集合。7 次探索没有显示收益;这组不是严格的 +交错对照,因此不据此宣称一个确定的退化比例。没有应用到源码。 + +### 2. Reflection.Emit P/Invoke:保留 + +动态生成与原声明相同的 Win32 方法: + +- Winapi calling convention; +- bool、IntPtr、uint32、by-ref 输出参数; +- Unicode desktop-name marshaling; +- 原来需要的 SetLastError 和 PreserveSig。 + +连接状态查询及 input-desktop 名称读取转为 PowerShell 包装函数,仍然释放 +WTS buffer 和 desktop handle。PMv2 设置仍在 WinForms/Drawing 加载前执行。 +原有前后 snapshot、destination CreateNew、flush、资源释放和内容无关失败回执 +保持不变。 + +主要改动在 [`src/helper/windows-capture.ps1`](../../src/helper/windows-capture.ps1)。 +决定依据见 [Decision 001](../specification/v1/decisions/001-command-scoped-windows-helper.md)。 + +### 3. 简化反射属性构造并合并程序集加载:未保留 + +在第 2 项基础上尝试少创建属性对象及合并 AssemblyName 加载。12 对模块级测试: +总体中位数仅低 0.4%,配对差中位数为 **-3 ms**,6/12 胜出。没有稳定收益,丢弃。 +这是一组组合探索,不用于证明其中任一修改单独有效或无效。 + +### 4. New-Object 换直接构造器:未保留 + +把 Bitmap/FileStream 的 `New-Object` 改为 `::new`,12 对 CLI 测试: +总体中位数看似低 7.5%,但配对差中位数为 **-19 ms**,只有 4/12 胜出。 + +这说明仅比较两组中位数可能被时序与分布误导。按配对证据拒绝该候选,源码保留 +原构造方式。 + +## 保留改动的结果 + +以下最终 CLI 测试以未修改 helper 为 baseline,以实际源码构建为 candidate。 +模块级初筛单独列出。 + +| 测量路径 | 区域 | 对数 | 原始中位数 | 新中位数 | 降幅 | 胜出 | +| --- | --- | ---: | ---: | ---: | ---: | ---: | +| 模块级初筛 | 400×300 | 12 | 1.304 s | 1.136 s | 12.9% | 11/12 | +| 完整 CLI | 400×300 | 20 | 1.590 s | 1.442 s | 9.3% | 20/20 | +| 完整 CLI | 1280×720 | 12 | 1.739 s | 1.585 s | 8.8% | 10/12 | + +两组最终 CLI 的配对节省时间中位数分别是 **155 ms** 和 **160 ms**。 +总体中位数之差与配对差中位数是不同统计量,不能互换。 +大图对照有两对明显的耗时波动;没有删除这些样本。 + +小图 CLI 的后段比前段慢,符合 retained-history 成本及环境波动的共同影响。 +不能声称每次 observe 都稳定落在某个固定时长,更不能把初筛的 12.9% 套用到 +所有任务。 + +## 回归与实际交付检查 + +- 新增“受控阻断 runtime C# compilation 仍能截图”的测试:旧 helper 为 + `capture_failed` / exit 1,新 helper 成功,四个随机颜色像素与尺寸均核对通过。 + 这是受控的编译依赖测试,不代表绕过 Windows 动态代码安全策略。 +- `npm test`:514 个测试,513 通过、0 失败、1 个因当前 Windows 无特权 + file-symlink 策略跳过。 +- 修复一个本轮暴露的测试竞争:`windows-input-parent.test.ts` 原来比较整个系统 + TEMP 的目录列表,另一个测试正常清理 `cu-input-helper-functions-*` 会造成误报。 + 现在给该测试进程独立 TEMP/TMP;input 执行器没有改变。 +- 打包后安装的 public E2E:observe 与 act 两个测试均通过。覆盖实际 target 像素、 + displays、actionable evidence、输入事件、checkpoint 和 unresolved-input 禁止重放。 +- 本机全局 `cu` 的 npm junction 指向当前仓库;源码、dist 与全局命令所用 capture + helper 的 SHA-256 一致,构建已生效,无需重新安装。 + +以上检查不新增全桌面隔离验收、物理多屏验收或符号链接权限豁免。 + +## 如何复测 + +先准备两个独立且已 build 的代码目录,一个是未修改 baseline,一个是 candidate。 +本仓库也需 build,以提供测试 fixture 支持。暂停其他桌面操作后运行: + +```powershell +npm run build +node scripts/benchmark-observe.mjs --baseline C:/builds/cu-before --candidate D:/builds/cu-after --rounds 20 --output C:/results/cu-observe.json +``` + +[`scripts/benchmark-observe.mjs`](../../scripts/benchmark-observe.mjs) 会打开仓库自有 +400×300 fixture,记录逐对 JSON,核验像素,最后清理窗口与临时 workspace。 +`--baseline` 可省略以测单个版本,但单版本数字不用于归因优化收益。 + +本轮详细记录位于本机 +`C:/Users/mapleland/ego/cu-observe-hillclimb-20261109/`: + +- `baseline-profile.json`:分项及 fs 调用计数; +- `emit-paired-1.json`、`emit-paired-1-summary.json`:模块级初筛; +- `emit-fast-paired.json`、`emit-fast-paired-summary.json`:反射组合微调; +- `final-cli-small.json`:最终 20 对 CLI 数据; +- `final-cli-large.json`、`final-cli-large-summary.json`:大图对照; +- `ctor-cli.json`:直接构造器候选的逐对数据; +- `large-fixture.ps1`、`large-pattern.json`、`paired-large.mjs`:大图临时实验材料。 + +分项插桩、各候选构建副本与原始结果不进入产品包。 + +## 下一次爬坡的方向与禁区 + +剩余重点是 PowerShell 固定启动开销和父进程文件系统/归档检查,尤其是历史增长时。 +值得继续拆解 `regular-file.ts` 与 `observation-archive.ts` 的重复工作,但必须先证明 +替代方案仍在所有使用、发布和 cutover 边界获得新鲜的身份与内容证据。 + +不得以这些方式制造收益: + +- 缓存桌面/session/topology 快照; +- 删除或跨不安全边界缓存 realpath、inode、父目录检查; +- 少检查 PNG、跳过最终落盘验证或 fsync; +- 测试前反复清空历史却把结果当成普通 retained-history 路径; +- 重放 act,或令 helper 跨命令存活。 + +本轮止于有明确证据、改动局部且通过受控 E2E 的收益,不宣称达到全局最优。 diff --git a/docs/research/observe-native-helper.md b/docs/research/observe-native-helper.md new file mode 100644 index 0000000..4d575d9 --- /dev/null +++ b/docs/research/observe-native-helper.md @@ -0,0 +1,118 @@ +# 原生 Capture Helper:实现与 Observe 对照 + +## 结果与当前状态 + +2026-11-09,用户明确允许原生重写,要求以保留功能及性能为准,不以重写成本排除方案。 +已将 `observe`、`displays` 和 action checkpoint 的 capture 后端切换为 **独立原生 C++ EXE**。 +Node 直接启动 `cu-capture.exe`,命令结束即退出。当前本机源码构建与全局 junction 安装已使用此路径。 + +**最终完整 CLI 对照约省 0.48–0.49 秒/次,32/32 对更快。** 没有常驻进程,未缓存桌面状态。 +input helper 保持原实现,所以 **整个 cu 仍需要 PowerShell 5.1 执行输入**;capture/displays +本身不再启动 PowerShell 或 CLR。生产 capture 失败时不回退到另一后端。 + +## 测量 + +用户说明同时运行游戏;实验不干预其负载。Windows x64,Node 24.15.0,基线为已做 +Reflection.Emit 优化的 stock PowerShell 5.1,不是更早每次编译 C# 的版本。 + +两边使用相同的当前 Node 代码、验证、归档与清理逻辑;独立构建副本仅替换 capture +helper 调度。每次新进程,OS 文件缓存已热,交错顺序轮转并反向。计时包含完整 +Node CLI 启动至退出,不含 fixture/init、之后的独立 PNG 解码及像素核对。 + +| 条件 | 每路次数 | 5.1 中位数 | 原生中位数 | 总体中位数降幅 | 配对节省中位数 | 原生更快 | +| --- | ---: | ---: | ---: | ---: | ---: | ---: | +| 400×300,每次新空归档 | 20 | 965.25 ms | 485.76 ms | 49.68% | 482.64 ms | 20/20 | +| 1280×720,逐轮保留等量历史 | 12 | 1,181.01 ms | 684.78 ms | 42.02% | 489.17 ms | 12/12 | + +最终 **64 次捕获均成功**,随机色块实际像素与尺寸核验全部通过,没有剔除失败样本或重试。 +两种尺寸的截图都来自测试自有 target;大尺寸 fixture 只在实验副本内放大,未抓取整个桌面或游戏。 +色块图像压缩率较高,不把结果外推为任意复杂图像的固定耗时。 + +初筛另有 400×300、20 对等量增长历史结果:1,097.00 → 634.50 ms,下降 42.16%, +配对省 479.76 ms,20/20 更快,40 次实际像素均通过。连同最终组共 104 次测量捕获成功。 + +空归档与有历史条件不可直接横比;总体中位数之差也不等于配对差中位数。 +结果支持保留原生改动,但没有给出对所有硬件、负载和长期历史的固定延迟保证。 + +[逐样本数据](data/observe-native-20261109.json)保留每次耗时、状态、图片大小和像素验证结果。 + +## 实现与行为边界 + +源码:[capture.cpp](../../src/helper/native/capture.cpp)。 + +- Win32 获取 PMv2 DPI awareness、进程 session、WTS connected 状态、可见 window station、 + input desktop、前台窗口及进程;只接受默认可交互桌面。 +- `GetSystemMetrics` / `EnumDisplayMonitors` / `GetMonitorInfoW` 获取显示拓扑,保持排序、 + 拓扑哈希及 display ID 的既有 JSON 字段顺序。 +- 保留 pixel、normalized、display_region、full_screen 四种 selector;负坐标、半开区域、 + 显示器绑定、全屏并集、尺寸限制和陈旧 ID 拒绝逻辑全部实现。 +- GDI `BitBlt(SRCCOPY)` 获取像素,GDI+ 24-bit bitmap 编码 PNG,继续使用原截图与编码技术。 + 本次没有同时改成 DXGI/WGC,性能收益可归因于移除 PowerShell/CLR 和脚本执行层。 +- 请求为最多 64 KiB 的规范 UTF-8 JSON;nlohmann/json 3.12.0 ordered JSON 加重复键拒绝、 + 深度上限、精确字段/标量/整数形态验证及规范序列化逐字节比较。 +- 目标文件限定在命令 TEMP 中,以 `CREATE_NEW`、独占打开和 `FlushFileBuffers` 写入, + 从同一持有句柄回读并计算 BCrypt SHA-256。 +- 截图前后完整环境身份必须一致;display 查询允许前台窗口变化,但桌面和拓扑必须一致。 +- 发布前失败通过**持有的文件句柄**标记删除,只清理本次创建的文件;原有文件不覆盖、不删除。 +- 输出仍为现有私有版本化协议,异常仅输出 `capture_failed`。Node 独立进行 PNG、字节、 + 哈希、文件身份、事务归档与 live observation 验证,资源/证据所有权不变。 + +命令 TEMP、真实路径及源文件校验仍由父进程负责。helper 没有工作区控制记录写入权限, +没有 native input 调用,没有跨命令桌面缓存。 + +## 构建、包与依赖 + +[build-native.mjs](../../scripts/build-native.mjs) 优先使用与 Node 架构匹配的 MinGW-w64, +不可用时使用 CMake/Visual Studio C++ 工具链。`CU_CXX` 可以显式指定 MinGW 编译器。 +本机实际验证过 GCC 14.2.0 与 MSVC 19.42 两条构建路径及各自的核心/实际像素测试。 + +- GCC x64 构建:380,416 字节,约 372 KiB。 +- MSVC x64 Release:333,824 字节,约 326 KiB。 +- 使用静态 C/C++ runtime 链接策略;PE imports 为 Windows 系统 DLL,未要求 MinGW DLL、 + 新 CLR 或另装图形库。 +- vendored JSON header 的版本、来源与 SHA-256 见 + [依赖记录](../../src/helper/native/vendor/README.md)。MIT notice 复制进安装包。 +- `npm run build` 编译 EXE;安装包带编译产物,用户无需安装编译器。 +- 历史 PowerShell capture 源码留在仓库用于对照和参考测试,不进入产品包,且不是运行时 fallback。 +- x64 是本次实测目标。其他架构虽有构建选项,尚无该架构的运行验收,不能因此声称已验证。 + +## 验证结果 + +- 原有完整回归:**513 通过,0 失败,1 个符号链接权限条件跳过**。 +- 原生行为测试:**4/4 通过**,覆盖 display 查询、30 组非法协议/selector、文件保留、 + Unicode 路径、实际随机 target 像素和 display-bound 捕获。GCC 与 MSVC 构建分别运行通过。 +- 原生核心测试:负 origin、normalized 边界、full-screen 并集、拓扑重复/溢出、display ID + 失效、前后环境身份、规范 JSON 与持有文件句柄的失败清理通过。 +- 包安装后的 observe E2E:**1/1 通过**;真实像素、归档、可行动证据均核验。 +- 包安装后的 act E2E:**1/1 通过**;受控 target 效果、无 decoy 效果、checkpoint、 + 未决输入禁止重放均核验。 + +原生测试源码:[协议与像素](../../test/windows-capture-native.test.mjs)、 +[核心行为](../../test/native/capture-core.cpp)。旧 PowerShell 源码结构检查仍存在,但不把它们 +当成新原生后端的行为证据。 + +格式化曾改变 Windows SDK include 顺序导致重建失败,已修复,并在 native 目录禁用 +include 自动排序;之后重建及包级 E2E 均通过。C++ 的实机编译/测试是有效验证证据; +不把没有配置完整 Windows SDK include 的 LSP/cpp-check 静默或启动失败当作 clean。 + +本轮没有隔离 VM/Sandbox 全桌面、锁屏、远程会话或显示器热插拔验收,沿用已有发布限制。 +full_screen 的选择与拓扑计算在合成用例验证,未在用户普通桌面上做全屏捕获。 + +## 复现 + +```powershell +npm run build +npm run test:native +node scripts/experiments/observe-native/prepare.mjs C:/cu-native-small small +node scripts/experiments/observe-powershell/measure.mjs C:/cu-native-small/manifest.json C:/cu-native-small/result.json 20 --fresh ps51 native +node scripts/experiments/observe-native/prepare.mjs C:/cu-native-large large +node scripts/experiments/observe-powershell/measure.mjs C:/cu-native-large/manifest.json C:/cu-native-large/result.json 12 ps51 native +``` + +输出目录必须不存在。所有桌面工作串行;不要同时运行两个 fixture、bench 或输入测试。 +测量器每个样本立即落盘,不因失败重试;`--fresh` 允许继续有限计划并独立报告失败数, +有历史模式则第一次失败即停止,避免两边历史数量失衡。 + +本机原始构建、编译器对照、日志及数据在 `C:/Users/mapleland/ego/cu-native-capture-20261109/`。 +设计决定和开发要求已同步;下一处可独立测量的热点是父进程归档与随 retained-history +增长的文件系统工作。 diff --git a/docs/research/observe-powershell7-and-dll.md b/docs/research/observe-powershell7-and-dll.md new file mode 100644 index 0000000..6619be4 --- /dev/null +++ b/docs/research/observe-powershell7-and-dll.md @@ -0,0 +1,203 @@ +# PowerShell 7 与 DLL:Observe 对比及 Hill Climb + +> 历史实验记录:本阶段结束时仍使用 5.1。随后完成并采用了 +> [原生 C++ capture helper](observe-native-helper.md);本文的基线与结果保持原样。 +> 当前复测脚本会在独立副本中重建 PowerShell 调度路径。 + +## 结论 + +2026-11-09,在用户同时运行游戏的 Windows 主机上,比较当前 PowerShell 5.1 +实现、pwsh 7.6.9、预编译 P/Invoke DLL,以及减少程序集依赖的组合候选。 + +**本轮不切换生产运行时。** pwsh 7 的完整 observe 比当前 5.1 慢;预编译 DLL +可以追回几十毫秒,但没有逆转结果。5.1 加小 DLL 的独立复核仅省约 12 ms。 +保留可复现实验工具和 DLL 源码,不把这点收益扩大为必须新增产品二进制依赖的理由。 + +最终两组共 **160 次捕获全部成功,像素全部核验通过**。实验未改 `src/`、 +产品打包配置、全局安装版运行时或 input helper。 + +## 测量口径 + +- Windows PowerShell:`5.1.26100.9711` / CLR `4.0.30319.42000`。 +- PowerShell 7:`7.6.9` / `.NET 10.0.14` / x64。 +- Node:`v24.15.0`。 +- 本机查询到两个显示器,虚拟屏幕为 `(-2560, 0, 5120, 1600)`;只截图仓库自有 + 400×300 target 客户区,不截图游戏或整个桌面。 +- 用户明确说明同时在运行游戏。保留这种负载;不关闭游戏,也不删去耗时较高的样本。 +- 测量 `node /dist/src/cli.js observe ...` 子进程启动到退出,含 helper、 + PNG 校验、归档发布、锁及清理;不含额外的 npm/PowerShell 命令 shim。 +- fixture 启动、workspace init、独立 PNG 解码与像素核对在计时区间外。 +- 每张图核对由 fixture 随机 token 决定的四个像素及尺寸,最后核对没有注入输入事件。 +- 最终主对照每次使用新的、已初始化的 workspace,均为首次 observe、空归档。 + 这防止失败导致两边历史数量失衡;不能把数字当作长历史 run 的耗时。 +- 多路测量采用轮转加反向顺序;两路初筛为 AB/BA。分别报告总体中位数、同轮配对 + 耗时差中位数、胜出对数、失败次数。总体中位数之差不等于配对差中位数。 +- 每次启动新的进程,但操作系统文件/程序集缓存已热;不是重启机器后的冷启动测试。 + +机器负载在不同实验时段变化明显,因此跨表比较绝对耗时没有归因意义。 +本文性能判断均基于同组交错配对。 + +## pwsh 7 的兼容性适配 + +未经适配的当前 helper 在 pwsh 7 下直接失败:`capture_failed` / exit 1。 +私有诊断确认 `.NET 10` 的 `System.AppDomain` 没有 `DefineDynamicAssembly`。 + +实验副本改用: + +```powershell +[Reflection.Emit.AssemblyBuilder]::DefineDynamicAssembly( + $assemblyName, [Reflection.Emit.AssemblyBuilderAccess]::Run +) +``` + +此 API 在本机 5.1 和 7 上都能运行。初始运行时对照两边使用相同的适配版 helper, +仅子进程 executable 不同。最终主对照则纳入完全未改的当前 5.1 构建。 + +更换 executable 时,仍从系统 Windows PowerShell 路径推导 `SYSTEMROOT/WINDIR`。 +不能把 `C:/Program Files/PowerShell/7` 向上三层当作 Windows 系统目录。 + +没有给公开 CLI 增加运行时开关;这些替换只发生在独立实验构建副本。 + +## 初始基线与分项 + +12 对、两边保留等量历史的完整 CLI 对照: + +| 方案 | 中位数 | pwsh 7 胜出 | 配对结果 | +| --- | ---: | ---: | ---: | +| 5.1,兼容 API | 1,650 ms | — | — | +| pwsh 7,兼容 API | 1,743 ms | 2/12 | 慢 110 ms | + +单独 16 对 fresh-process `-Command "exit 0"` 的启动耗时中位数: + +| 运行时 | 中位数 | +| --- | ---: | +| 5.1 | 188 ms | +| pwsh 7 | 232 ms | + +它只是进程启动的参考下限,不执行 helper,不能直接当作 observe 耗时。 + +helper 插桩还显示:pwsh 7 的原生方法初始化略快,但 `Add-Type` 加载程序集阶段更贵。 +四次初筛中,5.1 的 native-ready 中位数约 74 ms,pwsh 7 约 64 ms;从 native-ready +到 assemblies-ready 约为 57 ms 与 192 ms。这些数字用于定位,不是最终总收益。 + +## Hill Climb 候选 + +### 小型 P/Invoke DLL + +将 8 个原生函数声明预编译为 **3,584 字节的 managed AnyCPU DLL**,在命令内 +`Assembly.LoadFrom`。保留 PowerShell 包装函数及所有桌面、DPI、拓扑、协议、 +PNG、发布和清理检查。 + +源码:[CuCaptureNative.cs](../../scripts/experiments/observe-powershell/CuCaptureNative.cs)。 +使用系统 .NET Framework 4 的 `csc.exe` 构建,无额外 SDK 安装,5.1/7 均通过实测。 +这是构建一次、每个 helper 进程加载一次;不是常驻进程或缓存截图。 + +### 直接加载程序集 + +用带完整身份的 `Assembly.Load` 取代 `Add-Type -AssemblyName`,分别尝试单独使用 +以及与 DLL 组合。程序集加载阶段明显缩短,但首次 JSON cmdlet 模块加载推迟到 +后面:不能把阶段时间平移算成总体加速。 + +pwsh 7 单独替换的 12 对完整 CLI 初筛:1,762 → 1,754 ms,仅 0.45%,胜负 6/12。 +因此没有认定为稳定的独立收益。 + +### DLL 中使用 Win32 显示器枚举 + +另一个 **6,144 字节 DLL** 用 `GetSystemMetrics`、`EnumDisplayMonitors`、 +`GetMonitorInfoW` 提供 virtual-screen 与 monitor 信息,删除 WinForms 程序集依赖。 +排序、拓扑校验、前后 snapshot 与实际截图逻辑仍由原 helper 执行。 + +源码:[CuCaptureTopology.cs](../../scripts/experiments/observe-powershell/CuCaptureTopology.cs)。 +它与小 DLL 是两个独立构建候选,均定义 `CuCaptureNative`;不能合并到同一程序集编译。 + +本机双屏 `displays` 回执与原实现完全一致;测试覆盖负 origin、选择器验证与陈旧 +显示器绑定。没有新增锁屏、远程会话、镜像屏或显示设备热插拔的实机验收。 + +## 最终五路对照 + +空归档、每路 20 次、总计 100 次;每路 0 失败。完整 CLI 数据: + +| 方案 | 中位数 | 相对当前 5.1 的配对节省 | 比当前 5.1 快 | +| --- | ---: | ---: | ---: | +| 当前 5.1 | 957 ms | — | — | +| pwsh 7,兼容 API | 1,037 ms | -78 ms | 0/20 | +| pwsh 7 + 小 DLL | 1,008 ms | -48 ms | 2/20 | +| pwsh 7 + DLL + 直接加载 + 原生枚举 | 1,009 ms | -33 ms | 3/20 | +| 5.1 + DLL + 直接加载 + 原生枚举 | 929 ms | +27 ms | 19/20 | + +在同一组内,以未优化 pwsh 7 为基线: + +- 小 DLL:配对省 **30 ms**,16/20 胜出,总体中位数下降 2.74%。 +- 原生枚举组合:配对省 **38 ms**,18/20 胜出,总体中位数下降 2.70%。 +- 原生枚举组合相对小 DLL:配对反而慢 **3 ms**,9/20 胜出,不认定额外收益。 + +### 5.1 的 DLL 独立复核 + +另开 20 轮三路对照,总计 60 次;全部成功、像素通过: + +| 方案 | 中位数 | 相对当前 5.1 配对节省 | 胜出 | +| --- | ---: | ---: | ---: | +| 当前 5.1 | 952 ms | — | — | +| 5.1 + 小 DLL | 939 ms | 12 ms | 16/20 | +| 5.1 + DLL + 直接加载 + 原生枚举 | 937 ms | 22 ms | 18/20 | + +小 DLL 的总体中位数改善 1.41%;组合改善 1.61%。组合相对小 DLL 只配对省 7 ms, +12/20 胜出。证据不支持为了这个额外增量把 WinForms 枚举重写纳入生产路径。 + +## 中断与失败,不隐藏样本 + +原生枚举候选早期两组 growing-history 对照中断: + +- 第一组 5 次成功后出现 1 次 `capture_invalid`。该次没有保留私有异常,不能补写原因。 +- 第二组 22 次成功后出现 1 次 `capture_invalid`;诊断确认是原有的 + `environment_changed` 检查,未保留具体变化字段。 +- 用户说明同时运行游戏,这解释了负载波动的条件;它本身不能证明是哪一项环境身份变化。 +- 这两组不用于性能结论,原始日志保留;之后的 12 次诊断捕获均通过。 +- 最终 fresh 模式预先规定:失败计入记录、不重试,下一轮使用新 workspace;性能配对 + 仅使用同轮双方都成功的样本,并报告失败数。最终 160 次没有发生失败,无需排除任何样本。 + +所有环境检查原样保留;没有通过删除前后校验来使候选“通过”。 + +## 验证 + +六种配置运行了现有 capture-helper 测试:5.1 兼容版、pwsh 7 兼容版、两种运行时的小 DLL、 +以及两种运行时的原生枚举组合。每种 **13/13 通过**,合计 78 项;其中含现有源码结构检查。 +实际行为包括:随机 target 像素、编译不可用、非规范私有协议、现有文件保留、拓扑、 +选择器、display 查询和陈旧绑定拒绝。fixture 自身始终由 stock PowerShell 创建。 + +五路验证的公开 `displays --json` 回执完全一致。测试没有把图片路径当作像素验证。 +JavaScript 做了语法检查;两个 C# 源文件由真实 .NET Framework 编译器独立构建并执行。 +LSP 没有报告诊断,但 C# 两个文件的服务器未给出覆盖确认,因此以实际编译和运行结果为准。 + +## 复现 + +先在本仓库运行 `npm run build`。准备脚本要求输出目录不存在,避免覆盖其他实验。 +下面以本机默认安装路径示例: + +```powershell +node scripts/experiments/observe-powershell/prepare.mjs C:/cu-experiment "C:/Program Files/PowerShell/7/pwsh.exe" +node scripts/experiments/observe-powershell/verify.mjs C:/cu-experiment/manifest.json ps51-portable ps7-portable ps7-dll ps7-dll-load-native ps51-dll-load-native +node scripts/experiments/observe-powershell/measure.mjs C:/cu-experiment/manifest.json C:/cu-experiment/result.json 20 --fresh ps51-current ps7-portable ps7-dll ps7-dll-load-native ps51-dll-load-native +``` + +去掉 `--fresh` 会保留历史,并在第一次失败时停止,保证仍可比较等量历史。 +所有样本和失败都立即写入输出 JSON;脚本清理自己的临时 workspace 和 fixture。 +构建副本及 DLL 保留在所选输出目录,便于审查。运行时选择不会写回产品源码。 + +工具入口:[prepare.mjs](../../scripts/experiments/observe-powershell/prepare.mjs)、 +[measure.mjs](../../scripts/experiments/observe-powershell/measure.mjs)、 +[verify.mjs](../../scripts/experiments/observe-powershell/verify.mjs)、 +[startup.mjs](../../scripts/experiments/observe-powershell/startup.mjs)。 + +## 数据与后续判断 + +仓库中保留了 [逐样本 JSON](data/observe-powershell-20261109.json),包含初筛、 +两组最终矩阵、启动测量、分项摘要及中断说明。 +本机完整构建、原始日志和插桩脚本在 +`C:/Users/mapleland/ego/cu-pwsh7-hillclimb-20261109/`。 + +本轮不把 pwsh 7 作为提速路径,也不将更复杂的显示器枚举 DLL 纳入产品。 +小 DLL 是可用的备选,但 5.1 上的十几毫秒收益不足以成为当前最高优先级。 +若目标是进一步大幅降低 observe 延迟,下一步应测量父进程归档/文件系统工作, +或评估把更多 helper 逻辑移入独立编译组件的收益;都需要新的行为等价与发布验证, +不能用本轮 8 个 P/Invoke 声明的 DLL 结果代替。 diff --git a/docs/research/observe-without-powershell.md b/docs/research/observe-without-powershell.md new file mode 100644 index 0000000..5dcf143 --- /dev/null +++ b/docs/research/observe-without-powershell.md @@ -0,0 +1,116 @@ +# Observe 脱离 PowerShell 的路径 + +> 本文保留最初的路径比较与空进程测量。用户随后明确不以重写成本限制方案, +> 已实现并采用原生 C++ capture helper;当前结果见 +> [原生 helper 实测](observe-native-helper.md)。下文 C# 优先建议已被该决定替代。 + +## 建议 + +2026-11-09,在 PowerShell 7 和小 DLL 对照之后,优先评估 **命令级 C# EXE helper**。 +Node 直接启动 EXE,保留现有 stdin/stdout 私有协议和父进程验证、归档、发布职责。 +该路径可以去掉 PowerShell 宿主、脚本解释和 cmdlet 初始化,并继续在每条命令结束时退出。 + +本轮只验证独立程序的编译、执行及启动成本。尚未移植完整 capture helper, +没有更改生产执行器或声称完整 observe 已获得以下启动时间差对应的收益。 + +## 可行路径比较 + +| 路径 | 能消除的主要开销 | 代价与适合阶段 | +| --- | --- | --- | +| C# / .NET Framework EXE | PowerShell 宿主、脚本和 cmdlet;保留 CLR | 现有逻辑多为 .NET/PInvoke,迁移范围较小;首选原型 | +| C/C++/Rust 原生 EXE | PowerShell 和 CLR | 需要移植协议、Win32 结构、PNG 编码、错误与资源处理;后续性能候选 | +| 现代 .NET 自包含或 NativeAOT EXE | PowerShell;AOT 进一步避免运行时 JIT | 工具链、包体、目标架构和 native interop 构建要求更高;本轮未测 | +| Node 原生 addon / FFI | helper 子进程启动与 IPC | Node 本身没有通用内建 Win32 FFI;需额外桥接、目标架构产物及崩溃隔离设计 | +| 常驻 helper | 多次命令摊薄启动与图形初始化 | 改变当前命令级生命周期,新增身份、超时、崩溃、残余状态和恢复职责 | + +纯 JavaScript 无法凭 Node 标准库调用 BitBlt、WTS、桌面状态等 Win32 API。 +换成 Python ctypes 或 Bun FFI 可以减少某些桥接代码,但引入新的运行时/图像编码依赖, +目前没有证据比直接编译 helper 更合适。 + +现有设计明确使用 stock PowerShell、无必需 daemon。这些是当前实现与契约选择, +不是操作系统技术限制。EXE 生产迁移时应更新对应决定与发布条件;本轮仅生成实验产物。 + +## 启动成本实测 + +本机具备 .NET Framework `csc.exe`、GCC 14.2.0 和 .NET SDK 9.0.320。 +本轮使用前两者编译空程序,不安装工具、不下载依赖。用户此前说明同时运行游戏, +本轮不干预其负载。 + +20 轮五路轮转加反向测量,各程序仅启动后返回 0: + +| 程序 | 中位数 | 相对 5.1 配对节省 | 更快对数 | +| --- | ---: | ---: | ---: | +| Windows PowerShell 5.1 | 182.66 ms | — | — | +| pwsh 7.6.9 | 228.40 ms | -44.49 ms | 0/20 | +| C# / .NET Framework EXE | 50.59 ms | 132.19 ms | 20/20 | +| GCC 原生 EXE | 25.60 ms | 157.18 ms | 20/20 | +| Node 空进程 | 90.25 ms | 91.76 ms | 20/20 | + +计时包括从 Node `spawnSync` 启动子进程到退出;无 shell 包装,全部设置 `windowsHide`。 +这是每次新进程、操作系统文件缓存已热的测试,不是机器重启后的冷启动。 +全部 100 次运行 exit 0、stdout/stderr 为空。 + +C# 空 EXE 为 3,584 字节;原生空 EXE 为 14,848 字节。这不是未来完整 helper 的包体。 +原生空程序 imports 为系统 Kernel32/UCRT API sets;没有额外的 MinGW DLL import。 +真实图像编码与完整协议会改变依赖及体积。 + +**这些程序没有执行桌面校验、捕获、PNG 编码或归档。** 数字只证明运行时启动层 +存在可减少的开销;不能将完整 observe 直接写成 51 ms/26 ms,也不能简单减去此前 +另一时段的基线。完整 helper 的 CLR/JIT、库加载和任务成本必须在同组对照里重测。 + +[逐样本记录](data/observe-executable-startup-20261109.json)保留全部数据。 + +## 建议的最小迁移边界 + +第一步只迁移 capture/displays helper,保留 input helper: + +```text +Node observe + -> 创建命令 TEMP 与请求 + -> 直接启动 cu-capture.exe + -> stdin:现有版本化请求 + -> EXE:DPI、session/desktop、前后快照、区域捕获、PNG、清理 + -> stdout:现有版本化结果 + -> Node:验证内容与身份、归档、发布 live observation、释放锁 + -> EXE 与命令资源退出 +``` + +这不会要求更改公开 `cu observe` 回执或重新设计 archive。 +移植必须保留以下行为并对照验证: + +- UTF-8、请求大小、精确字段、规范数字与 JSON 形态、单一结果及无泄露诊断; +- PMv2 在图形初始化之前,session/input-desktop admission; +- 相同坐标映射、显示器身份和区域限制; +- 截图前后环境校验; +- destination CreateNew、PNG flush、hash、清理所有权; +- 父进程已有的完整 PNG、文件身份、事务发布及超时/退出分类。 + +现有测试中的运行行为可迁移为后端共同测试;PowerShell AST/源码结构检查不能 +直接当作 EXE 的验收。实际像素、非法协议、清理、环境变化、打包后 checkpoint +都需要复验。之后再测完整 CLI;有明确收益再修改产品构建和分发。 + +## 其他独立优化方向 + +**父进程归档/文件系统工作**应与 helper 迁移独立测量。此前 profile 中有约 +1,500 次 realpath/lstat 调用,历史增长也会增加成本。改用 EXE 不会自动消除它们。 +减少重复工作必须保留跨使用/发布边界的新鲜身份与内容证据。 + +**DXGI Desktop Duplication / Windows Graphics Capture**优化的是像素获取路径, +对连续、高频或特定窗口捕获可能更合适。目前单张 observe 的主热点包含启动和归档; +每命令新建 D3D/捕获对象的成本必须计入,不能套用视频连续帧吞吐数字。 + +**常驻 helper**可以进一步摊薄启动,但需要另立生命周期设计,不能偷偷让当前 helper +跨命令存活。当前推荐先验证无需 daemon 的独立 EXE。 + +## 复现启动测量 + +本仓库需已 build,以提供 stock PowerShell 路径解析支持。输出目录必须不存在: + +```powershell +node scripts/experiments/observe-powershell/executable-startup.mjs C:/cu-exe-startup D:/ProgramFiles/mingw64/bin/gcc.exe "C:/Program Files/PowerShell/7/pwsh.exe" +``` + +脚本:[executable-startup.mjs](../../scripts/experiments/observe-powershell/executable-startup.mjs)。 +源码:[EmptyHelper.cs](../../scripts/experiments/observe-powershell/EmptyHelper.cs)、 +[empty-helper.c](../../scripts/experiments/observe-powershell/empty-helper.c)。 +编译结果与原始数据在本机 `C:/Users/mapleland/ego/cu-executable-startup-20261109/`。 diff --git a/docs/research/product-boundaries-agent-desktop-codex.md b/docs/research/product-boundaries-agent-desktop-codex.md new file mode 100644 index 0000000..1a0949f --- /dev/null +++ b/docs/research/product-boundaries-agent-desktop-codex.md @@ -0,0 +1,327 @@ +# cu、agent-desktop 与 Codex Computer Use:差异化分野 + +调研日期:2026-11-09。本文是产品分析与建议,不修改现有执行合同。 + +## 结论先行 + +三者有交集,但不在完全相同的层次竞争: + +- **agent-desktop + agent-browser:模型中立的语义自动化工具链。** 原生应用 + 走 AX/UIA/AT-SPI;网页和可重新启动的 Electron 应用内容走浏览器工具。 + 价值是少猜坐标、按需读取树、利用控件操作和条件等待。 +- **Codex Computer Use:集成在 OpenAI 工作环境中的任务能力。** 它把模型、 + 浏览器、桌面控制、应用许可、代码修改和任务延续组合成使用体验。它不仅是 + 一个截图点击 API,也不只是纯视觉操作。 +- **cu:模型中立、图像证据绑定的有限输入执行器。** 更具体的分野是当前观察 + 的单次使用权限、确定性 checkpoint、输入意图持久化和不确定效果恢复。 + 它适合没有可靠语义操作通道、需要看渲染结果或必须使用物理输入的界面。 + +因此,cu 不宜把“CLI、开源、无内置模型、截图、安全、无需必需 daemon” +单独当作壁垒:agent-desktop 已覆盖其中多项,且有认真设计的身份和重试规则。 +更有意义的定位是: + +> 给任意 agent 提供可核查的视觉输入执行合同,补齐语义工具无法可靠覆盖的 +> 桌面操作与渲染状态验证,而不是再造一套通用浏览器或完整 AI 工作台。 + +这是建议,不是已经决定的永久 Non-Goal。若真实任务显示纯视觉执行器价值 +不足,应据此重新讨论范围,而不是用“底层工具”来回避能力缺口。 + +## 1. 本次证据与边界 + +### 1.1 已实际取得的材料 + +- 浏览器读取 agent-desktop 官方介绍、Windows 能力表、refs、headed、batch、 + recovery 和 Chromium/Electron 文档。[A1]–[A7] +- 从官方仓库页面确定源码提交 + `17467da5142d471b1e3a6b24828a5d3ad4d8c547`,取得固定提交下的核心源码和 + Windows 解析实现。该提交的 Cargo workspace 版本是 **1.1.0**;示例输出 + 中的 `version: "2.6"` 不能当作软件发行版本。[A8] +- 浏览器读取 Codex 官方更新及当前 Computer Use/Browser 文档。旧的 + `developers.openai.com/codex/computer-use` 入口目前重定向到 + `learn.chatgpt.com/docs/computer-use`,文档已经同时描述 ChatGPT Work 和 + Codex;以当前能力说明为准,不把 4 月首发范围当作今天的范围。[C1]–[C3] +- 阅读 DEV Community 文章、评论和 Hacker News 原帖,区分亲自试用、作者 + 自述与资料转述。[M1]–[M3] +- 核对 cu 本地提交 `d1b04f05f37233a7d8485a7d4ee4ac0a8510d791` 的 + `observeRegion`、`actRegion`、规范合同和现有 skill。[U1]–[U4] + +### 1.2 没有建立的结论 + +本轮没有安装 agent-desktop 二进制,没有运行 Codex 桌面组件,也没有做同一 +模型、同一任务的三方性能对照。源码取样不等于完整安全审计。对于 Codex, +只能说明公开能力与限制,不能推断它内部是否采用与 cu 相同的 journal、 +一次性 observation 或恢复协议。 + +Reddit 两个候选页面分别出现人机挑战和网络封锁,未绕过,未以搜索摘要 +代替评论证据。Hacker News 的旧 agent-desktop 原帖是作者说明且没有独立 +测试讨论,不能算独立口碑验证。 + +抓取文本、固定提交源码取样与本轮脚本在本机 +`C:/Users/mapleland/ego/cu-product-boundaries-20261109-1638/`。该目录不是 +产品发布产物,也不是其他环境续接本文的必要条件;公开链接在文末。 + +## 2. agent-desktop 的实质:控件身份与语义操作 + +### 2.1 它为何通常能省掉视觉推理 + +它读取操作系统无障碍树,为控件分配 `@:eN`。调用者可以直接 +表达 `set-value`、`check`、`expand`、`select`,而不是先用截图辨认控件,再 +移动鼠标、选中文字和逐个键入。[A1]、[A2] + +大窗口先 `snapshot --skeleton`,再对某个 ref `snapshot --root`,配合 +`-i`、`--compact`、深度限制和 `find` 减少返回量。注意:呈现的树更小,不 +等于身份校验完全只读小区域;当前 Windows/Linux ref 的唯一性证明仍针对 +原窗口,严格校验本身可能需要更完整的读取。[A3]、[A8] + +`headless` 不是一台隔离的虚拟电脑,而是多数 ref 动作调用语义 API,不使用 +用户的物理指针。Windows 中,被另一窗口遮住但未最小化的窗口仍可语义操作; +最小化元素通常是 offscreen,需 restore。物理输入和部分焦点操作仍要 +`--headed`。无作用的语义路径不会静默切到物理输入。[A2]、[A4] + +### 2.2 它并不是“没有截图、不会坐标、没有安全约束” + +当前产品有 `screenshot`、`--headed mouse-click --xy`、拖动、键盘输入、 +traces 和光标 overlay。其原始坐标点击源码检查策略、能力、坐标和 interaction +lease,但不要求传入截图 observation ID。[A8] + +refs 不是永久句柄:每次操作前,检查原进程/窗口与元素身份。Windows/Linux +要求捕获时唯一、当前仍唯一;macOS 可使用元素自身保留的地址。歧义、不完整 +身份和失效都有明确错误,不拿一个外观相似的元素凑数。[A3] + +它还区分 `not_delivered`、`delivery_uncertain`、`delivered_unverified`、 +`delivered_verified`、`unknown`,只有 `not_delivered` 对应 safe retry。 +cu 的“不要重复点击可能已执行的动作”不是独有理念。[A5]、[A8] + +### 2.3 具体缺口给了 cu 什么机会 + +1. **无可用语义树的内容。** 自绘 canvas、游戏视图、特殊绘图/编辑器区域 + 无法仅靠树解释。它仍能截图和物理点击,但需要外部视觉定位,并没有 cu + 的截图到输入权限合同。 +2. **同名同身份的重复控件。** 当前 Windows/Linux 的两个控件若 role、 + native id、name、description 都相同,就没有可用 ref 路径;钻入某行不 + 自动解除全窗口的身份歧义。几何位置可由外部视觉判断后走物理输入。[A3] +3. **语义树不反映渲染正确性。** 按钮存在、value 正确,不证明没有遮挡、 + 错位、颜色错误、图表渲染缺陷或画布编辑错误。此时需要视觉证据。 +4. **不能任意接管已经运行的 Electron 进程的 CDP。** 官方 `launch --cdp` + 要求新启动应用,并拒绝为已有进程偷偷重启;已有应用只能继续语义读取或 + 通过用户另行提供的浏览器连接工作。[A7] + +这些是可验证的细分场景,不意味着所有 Electron 应用都无法用语义自动化。 +官方 Windows 文档还提醒冷启动 Chromium 树可能要 10–25 秒才长完整;这是 +特定读取路径的限制,不能外推为每次 snapshot 都慢。[A2] + +### 2.4 与 agent-browser 的分工值得借鉴 + +agent-desktop 自己不实现 CDP 操作。它为新启动的 Chromium/Electron 程序 +开并核验 loopback DevTools endpoint,之后由 agent-browser 操作网页内容; +原生菜单、文件对话框、窗口、通知留在 agent-desktop。[A7] + +这是一个明确的模块边界,而不是“所有事情必须统一到一个 CLI”。cu 可以 +与现有浏览器/语义工具协作,不必为了完整性复制浏览器能力。 + +## 3. Codex Computer Use 的实质:集成与人机协作 + +### 3.1 当前公开能力 + +官方 Computer Use 文档描述在受支持地区,通过桌面应用给 ChatGPT Work 或 +Codex 启用控制能力,并按应用批准访问,可保存 Always allow。系统权限与 +应用批准分开,组织管理员还可以限制访问。[C1] + +- macOS 支持后台操作;官方 4 月更新还描述多个 agent 与用户并行。 +- **Windows 当前是前台操作**,目标应用必须在活动桌面可见,用户不应同时 + 在同一桌面抢用键鼠。官方建议使用第二台设备或 VM。 +- macOS 的 locked use 是另外启用的受控能力;Windows 仍是前台,不把它 + 等同为普通远程解锁功能,也不把这个设计移植为 cu 的绕锁目标。 +- 用户可以停止或接管。终端应用、ChatGPT 自身、管理员认证和系统安全许可 + 提示不在可自动化范围内。[C1] + +Codex 的 Computer Use 并不是“闭源版本的 cu”。它的价值还来自看界面、 +复现问题、修改代码、重新运行界面流程都处在同一个任务中,以及应用许可、 +浏览器标注、任务记忆和长期自动化的组合。[C2] + +### 3.2 它也在走混合通道 + +当前 Browser 文档明确区分内置浏览器与普通浏览器的 profile;需要已有浏览器 +会话时用扩展。Developer mode 可在明确批准后使用完整 CDP 来看 DOM、样式、 +性能和网络。Computer Use 文档也建议:有专用 plugin/MCP 时,对数据与重复 +操作优先使用结构化通道,视觉能力用于必要的界面操作。[C1]、[C3] + +因此不要建立“agent-desktop 语义、Codex/cu 完全纯视觉”的假二分。 +Codex 是多通道产品,cu 目前只是其中一种执行通道的独立实现。 + +### 3.3 与 cu 的分野 + +cu 可以交给 Pi、其他 agent 或脚本,模型与上层任务循环不固定;OpenAI 的 +桌面能力依赖其安装组件、权限管理与产品生态。这是相对于 Codex 的差异, +却不是相对于 agent-desktop 的差异。 + +本轮未确认 Codex 提供可供任意 agent 替换模型使用的独立桌面执行合同,也 +未验证它在 CLI 内的所有调用路径。不能从 Codex CLI 开源推导桌面组件也开源, +也不能仅凭未找到独立接口,断言 Computer Use 绝不可能由任何 CLI 调用。 + +若用户要的是“帮我把任务做完”,Codex 的集成完成度比一个有限输入 CLI 更 +贴近需求。cu 若要面向这种用户,必须增加上层产品;现有安全记录不能替代 +任务规划、可视化接管和业务结果验证。 + +## 4. 对照表 + +| 维度 | cu 当前实现 | agent-desktop + agent-browser | Codex Computer Use 公开能力 | +| --- | --- | --- | --- | +| 产品层 | 独立有限输入执行器 | 独立语义自动化工具链 | 集成任务能力与工作环境 | +| 模型 | 不内置;调用者选择 | 不内置;调用者选择 | 与 OpenAI 产品/模型体验组合 | +| 桌面观察 | 实际像素、图像与映射元数据 | OS 无障碍树;另有截图 | 视觉观察;配合应用和浏览器通道 | +| 操作目标 | 最新 observation 中的归一化坐标 | 当前能严格重识别的 ref;另有物理坐标 | 用户许可的应用与任务目标 | +| 证据生命周期 | 当前观察、TTL、单次消费;历史不可用于输入 | snapshot-qualified ref,每次重新识别;不是 cu 的单次消费协议 | 内部生命周期未公开核实 | +| 多步执行 | D2 有限前缀;视觉边界返回 checkpoint,丢弃尾部 | 同进程 batch、逐项结果、可等待;不是事务,默认错误后仍继续 | 内部任务循环;细节未核实 | +| 失败重试 | 持久 journal 未解决时挡住后续 act;partial/indeterminate 不重放 | disposition 指示是否 safe retry,严格 ref 与 actionability 检查 | 有接管/批准流程;内部效果恢复合同未知 | +| 背景操作 | Windows 物理前台输入,不提供隔离桌面 | 支持的语义动作可不抢指针;不是隔离 VM | macOS 后台,Windows 前台 | +| 平台 | Windows | macOS、Windows、Linux,具体动作不同 | 当前 Any App 文档列 macOS、Windows | +| 验证 | 调用者看最终像素/其他结果;输入成功不等于业务成功 | 属性、状态、等待及截图;语义验证不等于视觉正确 | 产品内看页面、复现、改代码、复验 | +| 集成 | CLI/skill;Pi 可按需 codemode 送图 | CLI、内置版本匹配 skill、C ABI、MCP、CDP 配套 | 应用许可、浏览器扩展、标注、plugins、长期任务 | + +## 5. cu 真正能守住的边界,以及不能夸大的部分 + +### 5.1 已有的具体执行合同 + +cu 的 `actRegion` 在输入前检查当前观察与环境、持有 run lock、确认无未解决 +效果状态,再写 durable intent。只有完成清理且计数一致才完成;需要视觉 +决策时发布新 observation,失败保留效果状态。`observeRegion` 只有在新证据 +发布后才可解决旧的未确定效果。[U1]、[U2] + +这个组合比泛泛的“截图后点一下”具体:调用者知道哪张图支撑这一段输入、 +哪些输入被发出、为何停止、下一张图是什么、旧观察为什么不能再用。 +它可以作为视觉 fallback 的可靠边界和执行诊断基础。 + +### 5.2 必须承认的限制 + +- observation 有效不证明界面像素在执行前完全没变;TTL 和环境检查不是 + 控件身份验证,也不是每次动作前重新做全图一致性断言。 +- 图片来源与坐标映射可信,不保证模型选对目标,更不保证指令语义安全。 +- 当前正常操作不以 foreground target identity 为输入门槛,也没有 Codex + 那样的应用许可产品界面。 +- run lock 是 run 范围;不同 run/workspace 不是不同物理桌面。需要上层 + 协调,不能把“可起多个 run”宣传成安全多 agent 并发。 +- journal 解决的是输入效果与恢复,不证明外部业务操作 exactly-once。 +- 清理和元数据脱敏不使截图本身不含隐私。远程模型收到图片后也不能称为 + 整个链路“数据不离开本机”。 +- cu 不是提示注入检测器、授权服务或沙箱。[U3] + +因此,不应宣称“cu 比它们更安全”。更准确的是执行合同的重点不同;是否 +对某类失败更可靠,要用故障注入与真实任务证明。 + +## 6. 效率:值得做什么,不值得复制什么 + +### 6.1 第一优先级:把当前视觉路径做好 + +1. 验证新版 skill 是否让模型默认把 `observe → read → image` 和 + `act → checkpoint image` 合在各自的一次 codemode 调用中。 +2. 分阶段计时 capture、helper、PNG 验证、事务发布与 input,不只统计工具 + 调用数。前一轮本机 400×300 小图 observe 中位数约 4.60 秒;PNG 文件读取 + 约 0.40–2.32 毫秒,未包含视觉编码和模型推理。[U4] +3. 把物理交互类型与文本微批次用好,不添加无用的 move-then-click、不再 + 采集已有 checkpoint。不要为了减少步骤自动放宽 D2 或续跑未知尾部。 +4. 提升第一次定位和最终验收的图像可用性;按需局部观察、预览缩放与坐标 + 映射可以研究,但不能靠盲目裁剪来隐藏定位证据。 + +cu 当前成本不仅是图片 token,还有输入与截图 helper 的启动、环境/记录检查 +和发布。agent-desktop 的原生 Rust 与同进程 batch/C ABI 减少了某些进程边界; +这构成需要比较的实现方向,不构成它在所有应用上更快的现成数字。 + +agent-desktop 的 batch 会预先检查输入,再按顺序运行,但不是事务。默认某项 +失败后后续项仍会运行,顶层 `ok: true` 也不意味着每项成功;依赖前一步的 +固定序列需要 `--stop-on-error` 并逐项读取 disposition。它不自动重试,也不能 +预先引用同一 batch 中尚未生成的 snapshot ref。[A6] + +### 6.2 第二优先级:工具分流,而不是先复制 60 个命令 + +建议上层按实际能力选择: + +```text +明确、稳定的数据/API操作 → 专用工具 +网页有可用 DOM/CDP → browser 工具 +原生控件有可靠语义操作 → agent-desktop 或其他语义工具 +必须看像素、特殊控件、真实拖动 → cu 的新观察 + 有限输入 +``` + +这是任务级选择,不是遇错自动升级权限。失败后先确认是否已执行;需要进入 +物理路径时重新观察并重新计划,不把 ref bounds 偷偷转换成已获授权的 cu +坐标。数据操作成功也不免除用户要求的视觉验收。 + +cu 的 skill 可以加入何时适合使用 cu、何时已有工具更合适的说明。若将来增加 +UIA,只应以真实覆盖不足为依据,并为语义身份另建合同,不能让旧 observation +ID 混用两种信任模型。本轮不修改 skill 的任务路由,留待定位讨论。 + +### 6.3 第三优先级:借鉴可观测性与协作 + +值得研究版本匹配的内置指南、动作边界上的产物、只用于呈现的光标 overlay、 +有界等待及明确的接管流程。像 Codex 那样的应用权限和人工接管,则属于上层 +产品治理,不是加一个 CLI flag 就能等价获得。 + +暂不以复制常驻 agent、记忆系统、计划任务、内置浏览器或 macOS 解锁为 cu +本轮优化目标。这些需要独立的产品决定,不是由竞品功能列表自动导出的需求。 + +## 7. 用什么测试决定这条分野是否成立 + +建议用用户自己的任务,并加入可精确核验的受控故障用例。相同模型、相同 +初始状态、相同输入策略;分别记录成功率、模型 usage、观察量、总耗时、 +错误恢复次数和人工介入。下面的预期是待验证假设,不是测试结果。 + +| 用例 | 为什么有辨别力 | 核验方式 | +| --- | --- | --- | +| 标准原生表单,包含中文输入与复选框 | 语义 set-value/check 可能比视觉输入更省步骤 | 实际字段读回、事件与最终界面 | +| 无语义标识的自绘区域/图表编辑 | 检验视觉路径是否真正覆盖语义工具缺口 | 应用状态和目标像素共同核验 | +| 每行完全同身份的重复按钮 | 检验 ref 歧义与视觉定位差异 | 精确目标行事件,其他行无效应 | +| 可新启动及不可重启的 Electron 应用 | 区分 CDP 快路径、UIA 冷树和已有会话成本 | 会话是否保留、实际页面结果 | +| 已点击但回执丢失;输入后截图发布失败 | 检验是否重复执行、是否保留不确定状态 | 目标/诱饵事件日志、状态记录 | +| 覆盖窗口、缩放与显示拓扑改变 | 检验物理目标、映射与拒绝边界 | 目标/诱饵事件与截图映射 | +| 相同业务状态但渲染错误 | 检验语义读回是否足够,视觉验收是否有效 | 预先定义的渲染缺陷和界面检查 | + +Codex 不能固定到完全相同的独立执行层时,应拆成“工具层机制测试”和 +“完整产品任务测试”。不要把不同模型的成功率差异全算在桌面工具头上。 + +## 8. 社区材料应如何解读 + +DEV 文章把 273 vs 3,811 tokens、模拟 52 步的 198k vs 31k 等数字明确列为 +项目作者自述,文章作者说没有亲自运行;本文不采用这些数字预测 cu 收益。 +它的“失败后改 headed”建议与当前官方禁止自行升级 headed 的规则冲突,应 +以当前官方 skill 和实现为准。[M1] + +旧 HN 作者帖给出 Obsidian 的 CDP/无障碍读取时长,也是作者样本,且早于本轮 +提交。帖中关于身份字段的说法不能覆盖当前严格身份实现。[M2] + +Codex 大型 HN 讨论中,用户 `cjbarber` 的试用反馈认为许可流程顺畅、后台 +浏览器测试方便,但也遇到少量焦点被占用、功能入口难找到等问题。这说明 +集成与可发现性有价值,仍不意味着后台能力在每个平台、每个动作都无干扰。 +它是个人体验,不是当前版本的对照测试。[M3] + +可得出的产品启发:用户不仅要“模型能点”,还要低打扰、能知道发生了什么、 +能方便启动正确能力、能在出错时接管。不能从点赞、星数或自报 token 节约 +推出生产任务成功率。 + +## 来源 + +[A1]: https://agent-browser.dev/desktop +[A2]: https://agent-browser.dev/desktop/platforms/windows +[A3]: https://agent-browser.dev/desktop/snapshots-and-refs +[A4]: https://agent-browser.dev/desktop/guides/headed-mode +[A5]: https://agent-browser.dev/desktop/errors-and-recovery +[A6]: https://agent-browser.dev/desktop/guides/batch +[A7]: https://agent-browser.dev/desktop/guides/chromium-and-electron +[A8]: https://github.com/vercel-labs/agent-desktop/tree/17467da5142d471b1e3a6b24828a5d3ad4d8c547 +[C1]: https://learn.chatgpt.com/docs/computer-use +[C2]: https://openai.com/index/codex-for-almost-everything/ +[C3]: https://learn.chatgpt.com/docs/browser +[M1]: https://dev.to/gabrielanhaia/vercels-agent-desktop-lets-coding-agents-click-native-apps-without-moving-your-mouse-38p1 +[M2]: https://news.ycombinator.com/item?id=49307819 +[M3]: https://news.ycombinator.com/item?id=47796469 +[U1]: ../specification/v1/contracts/action-and-evidence.md +[U2]: ../../src/act.ts +[U3]: ../../SECURITY.md +[U4]: efficiency-and-pi-image-delivery.md + +agent-desktop 源码核对点:`crates/core/src/refs/resolve_saved_ref.rs`、 +`refs/refs_store.rs`、`ref_action/mod.rs`、`actions/delivery_semantics.rs`、 +`commands/mouse_click.rs`、`commands/screenshot.rs`、`src/batch/mod.rs`、 +`crates/windows/src/tree/resolve/resolve_search.rs` 和 +`skills/agent-desktop/SKILL.md`。源码中相关行为与本文的官方文档比较对应; +没有据此声称全部分支已在本机运行。 diff --git a/docs/specification/v1/decisions/001-command-scoped-windows-helper.md b/docs/specification/v1/decisions/001-command-scoped-windows-helper.md index 346bfd1..fb6ea7f 100644 --- a/docs/specification/v1/decisions/001-command-scoped-windows-helper.md +++ b/docs/specification/v1/decisions/001-command-scoped-windows-helper.md @@ -8,10 +8,11 @@ and `act` commands must not leave a helper, held input, or cleanup obligation be ## Decision -Use a stock Windows PowerShell 5.1 helper with embedded C# P/Invoke for Windows-only -observation and input. The Node CLI starts a helper only for the command that needs it, -uses a private versioned protocol, validates every response, then terminates the helper -and releases command-owned resources. +Use a bundled native C++ executable (`cu-capture.exe`) for Windows observation and +display queries. Input retains stock Windows PowerShell 5.1 with embedded C# P/Invoke. +The Node CLI starts a helper only for the command that needs it, uses a private +versioned protocol, validates every response, then releases command-owned resources. +Capture never falls back to another runtime after an executable failure. The helper is an untrusted boundary with no authority to write workspace control records. The CLI owns archive installation, live-observation replacement, effect @@ -21,8 +22,41 @@ journaling, result receipts, and final cleanup classification. - A persistent daemon would reduce startup cost but creates cross-command state, liveness, and recovery obligations prohibited by the product design. -- A native Node addon would require a Windows compilation and binary distribution - supply chain inconsistent with the no-extra-installation direction. +- A native Node addon would move desktop calls and native failures into the CLI + process. The standalone EXE keeps the existing process/protocol isolation. +- C# EXE, native EXE, and PowerShell variants were measured; native capture removes + both the PowerShell and CLR startup layers without requiring a daemon. + +## 2026-11-09: Capture Initialization Refinement + +Phase profiling identified per-command C# compilation as avoidable capture overhead. +Capture initially emitted equivalent P/Invoke declarations in the helper's CLR, retaining +Winapi calling convention, Unicode desktop-name marshaling, SetLastError and +PreserveSig. Desktop/session admission, DPI awareness, pre/post environment checks, +PNG validation, transactional publication and command cleanup are unchanged. + +This refinement adds no precompiled binary, native addon, durable cache or helper +session. Input remains unchanged. A runtime-compilation-unavailable regression test +checks real owned-window pixels, and alternating baseline/candidate benchmarks +measure the complete observe path; see the +[hill-climb record](../../../research/observe-latency-hillclimb.md). + +## 2026-11-09: Native Capture Endpoint + +The operator explicitly permits a native rewrite and prioritizes retained functionality +and measured performance over rewrite effort. The capture endpoint is now native code: +Win32 session/desktop/topology queries, GDI pixels, GDI+ PNG, BCrypt SHA-256, strict +bounded UTF-8 JSON, CreateNew output, flush/readback and pre/post environment comparison. +The protocol, Node validation, archive ownership and evidence boundary remain intact. + +Failed output is deleted using the owned open file handle. The helper retains no desktop +state across commands. The PowerShell capture source stays as a development comparison +reference; it is not a production fallback or a packaged runtime dependency. + +Source builds need a Windows C++ toolchain. Packages include the compiled executable +and the JSON library's MIT notice; consumers install no compiler, CLR component, or +new runtime for capture. Input still needs Windows PowerShell. Performance and verification +are recorded in the [native capture experiment](../../../research/observe-native-helper.md). ## Consequences diff --git a/docs/specification/v1/scope.md b/docs/specification/v1/scope.md index 4305d09..b872a21 100644 --- a/docs/specification/v1/scope.md +++ b/docs/specification/v1/scope.md @@ -40,8 +40,9 @@ processes. ## Hard Constraints - `cu` is a standalone Node/TypeScript ESM CLI with no required host runtime. -- Observation and input use a command-scoped stock Windows PowerShell 5.1 helper; - no model-visible or required persistent daemon exists. +- Observation and display queries use a bundled command-scoped native executable; + input uses a command-scoped stock Windows PowerShell 5.1 helper. No model-visible + or required persistent daemon exists. - Current-host verification effects are limited to the test-owned controlled fixture. Full-desktop effects or acceptance never use the ordinary developer desktop. diff --git a/package.json b/package.json index d0feb43..8fb1f73 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ }, "files": [ "dist/src/*.js", - "dist/helper/windows-capture.ps1", + "dist/helper/cu-capture.exe", + "dist/helper/LICENSE.nlohmann-json", "dist/helper/windows-input.ps1", "README.md", "LICENSE" @@ -37,11 +38,12 @@ }, "scripts": { "clean": "node scripts/clean.mjs", - "build": "npm run clean && tsc -p tsconfig.json && node scripts/copy-assets.mjs", + "build": "npm run clean && tsc -p tsconfig.json && node scripts/copy-assets.mjs && node scripts/build-native.mjs", + "test:native": "node scripts/build-native.mjs --test && node --test --test-concurrency=1 test/windows-capture-native.test.mjs", "typecheck": "tsc -p tsconfig.json --noEmit", "test:ci": "npm run build && node --test dist/test/action-file.test.js dist/test/strict-json.test.js dist/test/observation-record.test.js dist/test/effect-journal.test.js dist/test/effect-plan.test.js dist/test/history-event.test.js dist/test/archive-transaction.test.js dist/test/png.test.js dist/test/capture-bundle.test.js", "smoke:ci": "node scripts/ci-smoke.mjs", - "test": "npm run build && node --test dist/test/init-help.e2e.test.js dist/test/status.e2e.test.js dist/test/regular-file.test.js dist/test/run-status.e2e.test.js dist/test/run-store.test.js dist/test/run-lock-concurrency.test.js dist/test/action-file.test.js dist/test/action-input.test.js dist/test/strict-json.test.js dist/test/observation-record.test.js dist/test/effect-journal.test.js dist/test/effect-plan.test.js dist/test/effect-store.test.js dist/test/effect-archive-resolution.test.js dist/test/history-event.test.js dist/test/archive-transaction.test.js dist/test/archive-store.test.js dist/test/archive-layout.test.js dist/test/png.test.js dist/test/capture-bundle.test.js dist/test/windows-display.test.js dist/test/windows-capture-parent.test.js dist/test/windows-capture-helper.test.js dist/test/windows-input-parent.test.js dist/test/windows-input-helper.test.js dist/test/windows-input-timing.test.js dist/test/observation-archive.test.js dist/test/archive-query.test.js dist/test/status-query.test.js dist/test/archive-cleanup.test.js dist/test/observation-archive-clear.test.js dist/test/observe-cli.test.js dist/test/act.test.js dist/test/act-cli.test.js dist/test/history-cli.test.js dist/test/clear-cli.test.js", + "test": "npm run build && node --test dist/test/init-help.e2e.test.js dist/test/status.e2e.test.js dist/test/regular-file.test.js dist/test/run-status.e2e.test.js dist/test/run-store.test.js dist/test/run-lock-concurrency.test.js dist/test/action-file.test.js dist/test/action-input.test.js dist/test/strict-json.test.js dist/test/observation-record.test.js dist/test/effect-journal.test.js dist/test/effect-plan.test.js dist/test/effect-store.test.js dist/test/effect-archive-resolution.test.js dist/test/history-event.test.js dist/test/archive-transaction.test.js dist/test/archive-store.test.js dist/test/archive-layout.test.js dist/test/png.test.js dist/test/capture-bundle.test.js dist/test/windows-display.test.js dist/test/windows-capture-parent.test.js dist/test/windows-capture-helper.test.js dist/test/windows-input-parent.test.js dist/test/windows-input-helper.test.js dist/test/windows-input-timing.test.js dist/test/observation-archive.test.js dist/test/archive-query.test.js dist/test/status-query.test.js dist/test/archive-cleanup.test.js dist/test/observation-archive-clear.test.js dist/test/observe-cli.test.js dist/test/act.test.js dist/test/act-cli.test.js dist/test/history-cli.test.js dist/test/clear-cli.test.js && npm run test:native", "test:observe-region:e2e": "npm run build && node --test dist/test/observe-region.public-e2e.test.js", "test:act-controlled:e2e": "npm run build && node --test --test-concurrency=1 dist/test/act-controlled.public-e2e.test.js", "test:archive-admin:e2e": "npm run build && node --test --test-concurrency=1 dist/test/archive-admin.public-e2e.test.js", diff --git a/scripts/benchmark-observe.mjs b/scripts/benchmark-observe.mjs new file mode 100644 index 0000000..0a23131 --- /dev/null +++ b/scripts/benchmark-observe.mjs @@ -0,0 +1,118 @@ +// Development-only live benchmark. Capture only the repository-owned fixture. +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join, resolve } from "node:path"; +import { performance } from "node:perf_hooks"; +import { fileURLToPath, pathToFileURL } from "node:url"; + +const repositoryRoot = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +const argumentsList = process.argv.slice(2); +const options = new Map(); +for (let index = 0; index < argumentsList.length; index += 2) { + const name = argumentsList[index]; + const value = argumentsList[index + 1]; + if (!["--baseline", "--candidate", "--rounds", "--output"].includes(name) || value === undefined || options.has(name)) { + throw new Error("Usage: node scripts/benchmark-observe.mjs [--baseline BUILT_ROOT] [--candidate BUILT_ROOT] [--rounds N] [--output FILE]"); + } + options.set(name, value); +} +const rounds = Number(options.get("--rounds") ?? 12); +if (!Number.isSafeInteger(rounds) || rounds < 3 || rounds > 100) { + throw new Error("--rounds must be an integer in 3..100"); +} +if (process.platform !== "win32") throw new Error("This benchmark needs an interactive Windows desktop."); + +const fixtureSupport = await import(pathToFileURL(join(repositoryRoot, "dist/test/support/controlled-window.js"))); +const { initializeWorkspace } = await import(pathToFileURL(join(repositoryRoot, "dist/src/workspace.js"))); +const variants = [ + ...(options.has("--baseline") ? [{ name: "baseline", root: resolve(options.get("--baseline")) }] : []), + { name: "candidate", root: resolve(options.get("--candidate") ?? repositoryRoot) }, +]; +for (const variant of variants) { + // Fail on a missing build before opening a desktop window. + readFileSync(join(variant.root, "dist/src/cli.js")); + assert.ok(existsSync(join(variant.root, "dist/helper/cu-capture.exe")) || existsSync(join(variant.root, "dist/helper/windows-capture.ps1")), "capture build missing"); +} + +const samples = []; +let fixture; +try { + for (const variant of variants) { + variant.workspace = mkdtempSync(join(tmpdir(), "cu-observe-benchmark-")); + initializeWorkspace(variant.workspace); + } + fixture = await fixtureSupport.startControlledWindowFixture(); + const rectangle = fixture.target; + const selector = `pixel:${rectangle.x},${rectangle.y},${rectangle.width},${rectangle.height}`; + const colors = fixtureSupport.deriveControlledPatternColors(fixture.token); + const pattern = fixtureSupport.readControlledPattern(); + for (let pair = 0; pair < rounds; pair += 1) { + // Alternate AB/BA, keep retained-history counts equal, and never compete for desktop input. + const order = pair % 2 === 0 ? variants : variants.toReversed(); + for (const variant of order) { + const started = performance.now(); + const execution = spawnSync( + process.execPath, + [join(variant.root, "dist/src/cli.js"), "observe", "benchmark", "--region", selector, "--json"], + { cwd: variant.workspace, encoding: "utf8", shell: false, timeout: 30_000, maxBuffer: 1_048_576 }, + ); + const totalMs = performance.now() - started; + assert.equal(execution.status, 0, execution.stderr + execution.stdout); + assert.equal(execution.stderr, ""); + const receipt = JSON.parse(execution.stdout); + assert.equal(receipt.kind, "cu.observe.result/v1"); + const bytes = readFileSync(join(variant.workspace, receipt.imagePath)); + const decoded = fixtureSupport.decodePngRgba(bytes); + assert.equal(decoded.width, rectangle.width); + assert.equal(decoded.height, rectangle.height); + for (const [index, point] of pattern.samples.entries()) { + assert.deepEqual(fixtureSupport.sampleRgb(decoded, point.x, point.y), colors.target[index]); + } + const sample = { pair, variant: variant.name, totalMs, imageBytes: bytes.length, pixelsVerified: true }; + samples.push(sample); + console.log(JSON.stringify(sample)); + } + } + assert.deepEqual(await fixture.snapshotAndClear(), { target: [], decoy: [] }); + const median = (values) => { + const sorted = [...values].sort((left, right) => left - right); + return (sorted[Math.floor((sorted.length - 1) / 2)] + sorted[Math.floor(sorted.length / 2)]) / 2; + }; + const timings = (name) => samples.filter((sample) => sample.variant === name).map((sample) => sample.totalMs); + const summary = { + rounds, + region: rectangle, + candidateMedianMs: median(timings("candidate")), + candidateMinMs: Math.min(...timings("candidate")), + candidateMaxMs: Math.max(...timings("candidate")), + }; + if (options.has("--baseline")) { + summary.baselineMedianMs = median(timings("baseline")); + const saved = Array.from({ length: rounds }, (_, pair) => { + const baseline = samples.find((sample) => sample.pair === pair && sample.variant === "baseline"); + const candidate = samples.find((sample) => sample.pair === pair && sample.variant === "candidate"); + return baseline.totalMs - candidate.totalMs; + }); + summary.pairedMedianSavedMs = median(saved); + summary.pairsWon = saved.filter((value) => value > 0).length; + summary.reduction = 1 - summary.candidateMedianMs / summary.baselineMedianMs; + } + const result = { + note: "CLI child process wall time; fixture setup, init, independent PNG verification and cleanup excluded. Equal growing histories; AB/BA ordering; no input injected.", + runtimes: variants.map(({ name, root }) => ({ name, root })), + summary, + samples, + }; + if (options.has("--output")) writeFileSync(resolve(options.get("--output")), `${JSON.stringify(result, null, 2)}\n`); + console.log(JSON.stringify(summary)); +} finally { + try { + if (fixture !== undefined) await fixture.stop(); + } finally { + for (const variant of variants) { + if (variant.workspace !== undefined) rmSync(variant.workspace, { recursive: true, force: true }); + } + } +} diff --git a/scripts/build-native.mjs b/scripts/build-native.mjs new file mode 100644 index 0000000..444438b --- /dev/null +++ b/scripts/build-native.mjs @@ -0,0 +1,43 @@ +// Build a command-scoped native helper; no desktop access during compilation/core tests. +import { spawnSync } from "node:child_process"; +import { copyFileSync, mkdirSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +const repositoryRoot = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +const sourceRoot = join(repositoryRoot, "src/helper/native"); +const outputRoot = join(repositoryRoot, "dist/helper"); +const testCore = process.argv.includes("--test"); +if (process.argv.slice(2).some((arg) => arg !== "--test")) throw new Error("Usage: node scripts/build-native.mjs [--test]"); +if (process.platform !== "win32") throw new Error("The cu native helper must be built on Windows."); +mkdirSync(outputRoot, { recursive: true }); +function run(executable, args) { + // Build-only compiler selection is operator configuration; argv is separate and no shell is used. + // nosemgrep: javascript.lang.security.detect-child-process.detect-child-process + const result = spawnSync(executable, args, { cwd: repositoryRoot, encoding: "utf8", windowsHide: true, shell: false, timeout: 180_000, maxBuffer: 4_194_304 }); + if (result.stdout) process.stdout.write(result.stdout); + if (result.stderr) process.stderr.write(result.stderr); + if (result.error || result.status !== 0) throw new Error(`Native build command failed: ${executable}`, { cause: result.error }); +} +const compiler = process.env.CU_CXX ?? "g++"; +const probe = spawnSync(compiler, ["-dumpmachine"], { encoding: "utf8", windowsHide: true, shell: false, timeout: 10_000 }); +const triple = probe.stdout?.trim() ?? ""; +const matchesArchitecture = (process.arch === "x64" && triple.startsWith("x86_64")) || (process.arch === "arm64" && triple.startsWith("aarch64")) || (process.arch === "ia32" && /^i[3-6]86/.test(triple)); +if (probe.status === 0 && triple.includes("mingw") && matchesArchitecture) { + const flags = ["-std=c++17", "-O2", "-s", "-static", "-static-libgcc", "-static-libstdc++", "-DUNICODE", "-D_UNICODE", "-D_WIN32_WINNT=0x0A00", "-Wall", "-Wextra", "-Wpedantic", "-Werror"]; + const libraries = ["-luser32", "-lgdi32", "-lgdiplus", "-lole32", "-lbcrypt", "-lwtsapi32"]; + run(compiler, [...flags, join(sourceRoot, "capture.cpp"), "-o", join(outputRoot, "cu-capture.exe"), ...libraries]); + if (testCore) run(compiler, [...flags, join(repositoryRoot, "test/native/capture-core.cpp"), "-o", join(outputRoot, "cu-capture-core.exe"), ...libraries]); +} else { + if (process.env.CU_CXX) throw new Error("CU_CXX must name a MinGW compiler matching the Node process architecture."); + const buildRoot = join(repositoryRoot, "dist/native-build"); + const architecture = { x64: "x64", arm64: "ARM64", ia32: "Win32" }[process.arch]; + if (!architecture) throw new Error(`Unsupported native build architecture: ${process.arch}`); + // Default CMake discovery uses the installed Visual Studio C++ toolchain on Windows. + run("cmake", ["-S", sourceRoot, "-B", buildRoot, "-A", architecture, `-DCU_BUILD_TESTS=${testCore ? "ON" : "OFF"}`]); + run("cmake", ["--build", buildRoot, "--config", "Release", "--parallel", "2"]); + copyFileSync(join(buildRoot, "Release/cu-capture.exe"), join(outputRoot, "cu-capture.exe")); + if (testCore) copyFileSync(join(buildRoot, "Release/cu-capture-core.exe"), join(outputRoot, "cu-capture-core.exe")); +} +copyFileSync(join(sourceRoot, "vendor/LICENSE.nlohmann-json"), join(outputRoot, "LICENSE.nlohmann-json")); +if (testCore) run(join(outputRoot, "cu-capture-core.exe"), []); +console.log(`Native capture helper built for ${process.arch}`); diff --git a/scripts/ci-smoke.mjs b/scripts/ci-smoke.mjs index abe8126..2391447 100644 --- a/scripts/ci-smoke.mjs +++ b/scripts/ci-smoke.mjs @@ -59,6 +59,10 @@ for (const helper of ["windows-capture.ps1", "windows-input.ps1"]) { ); } +const nativeHelper = readFileSync(resolve(repositoryRoot, "dist/helper/cu-capture.exe")); +assert.equal(nativeHelper.subarray(0, 2).toString("ascii"), "MZ", "native capture build missing"); +assert.ok(readFileSync(resolve(repositoryRoot, "dist/helper/LICENSE.nlohmann-json"), "utf8").includes("MIT License")); + const workspace = mkdtempSync(join(tmpdir(), "cu-ci-smoke-")); try { const result = spawnSync( diff --git a/scripts/experiments/observe-native/prepare.mjs b/scripts/experiments/observe-native/prepare.mjs new file mode 100644 index 0000000..1ed1c21 --- /dev/null +++ b/scripts/experiments/observe-native/prepare.mjs @@ -0,0 +1,46 @@ +// Build independent baseline/native copies for the shared observe matrix runner. +import assert from "node:assert/strict"; +import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; +import { dirname, isAbsolute, join, resolve } from "node:path"; +import { fileURLToPath, pathToFileURL } from "node:url"; +const repositoryRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../../.."); +const [destination, size = "small"] = process.argv.slice(2); +if (!destination || !isAbsolute(destination) || !["small", "large"].includes(size)) throw new Error("Usage: node scripts/experiments/observe-native/prepare.mjs NEW_ABSOLUTE_DIRECTORY [small|large]"); +if (existsSync(destination)) throw new Error("Output directory must not exist."); +const { stockPowerShellPath } = await import(pathToFileURL(join(repositoryRoot, "dist/test/support/controlled-window.js"))); +const stock = stockPowerShellPath(); +mkdirSync(destination, { recursive: true }); +const replace = (text, old, next) => { assert.equal(text.split(old).length, 2, `Source adaptation changed: ${old}`); return text.replace(old, next); }; +const variants = []; +for (const name of ["ps51", "native"]) { + const root = join(destination, name); + mkdirSync(root); + cpSync(join(repositoryRoot, "dist"), join(root, "dist"), { recursive: true }); + cpSync(join(repositoryRoot, "test/fixtures"), join(root, "test/fixtures"), { recursive: true }); + cpSync(join(repositoryRoot, "package.json"), join(root, "package.json")); + if (name === "ps51") { + const path = join(root, "dist/src/windows-capture.js"); + let source = replace(readFileSync(path, "utf8"), 'new URL("../helper/cu-capture.exe", import.meta.url)', 'new URL("../helper/windows-capture.ps1", import.meta.url)'); + const args = ["-NoLogo", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File"]; + source = replace(source, "spawnSync(helperPath, [], {", `spawnSync(${JSON.stringify(stock)}, [...${JSON.stringify(args)}, helperPath], {`); + writeFileSync(path, source); + } + variants.push({ name, root }); +} +const fixtureRoot = variants[1].root; +if (size === "large") { + const fixture = join(fixtureRoot, "test/fixtures/controlled-window/fixture.ps1"); + let source = readFileSync(fixture, "utf8"); + for (const [old, next] of [["Size(400, 300)", "Size(1280, 720)"], ["{ 0 } else { 200 }", "{ 0 } else { 640 }"], ["{ 0 } else { 150 }", "{ 0 } else { 360 }"], ["$x, $y, 200, 150)", "$x, $y, 640, 360)"]]) source = replace(source, old, next); + writeFileSync(fixture, source); + const patternPath = join(fixtureRoot, "test/fixtures/controlled-window/pattern.json"); + let pattern; + try { pattern = JSON.parse(readFileSync(patternPath, "utf8")); } + catch (cause) { throw new Error("Invalid fixture pattern", { cause }); } + pattern.width = 1280; + pattern.height = 720; + pattern.samples.forEach((point) => { point.x = Math.round(point.x * 1280 / 400); point.y = Math.round(point.y * 720 / 300); }); + writeFileSync(patternPath, `${JSON.stringify(pattern, null, 2)}\n`); +} +writeFileSync(join(destination, "manifest.json"), `${JSON.stringify({ note: "Native vs legacy PowerShell with identical current parent validation and archive code. Fixture changes only in this experiment copy.", fixtureRoot, variants }, null, 2)}\n`); +console.log(join(destination, "manifest.json")); diff --git a/scripts/experiments/observe-powershell/CuCaptureNative.cs b/scripts/experiments/observe-powershell/CuCaptureNative.cs new file mode 100644 index 0000000..afbf8d6 --- /dev/null +++ b/scripts/experiments/observe-powershell/CuCaptureNative.cs @@ -0,0 +1,13 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; +public static class CuCaptureNative { + [DllImport("user32.dll")] public static extern bool SetProcessDpiAwarenessContext(IntPtr value); + [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow(); + [DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint processId); + [DllImport("user32.dll", SetLastError=true)] public static extern IntPtr OpenInputDesktop(uint flags, bool inherit, uint access); + [DllImport("user32.dll")] public static extern bool CloseDesktop(IntPtr desktop); + [DllImport("user32.dll", SetLastError=true, CharSet=CharSet.Unicode)] public static extern bool GetUserObjectInformation(IntPtr handle, int index, StringBuilder value, int length, out int needed); + [DllImport("wtsapi32.dll", SetLastError=true)] public static extern bool WTSQuerySessionInformation(IntPtr server, int sessionId, int infoClass, out IntPtr buffer, out int bytesReturned); + [DllImport("wtsapi32.dll")] public static extern void WTSFreeMemory(IntPtr buffer); +} diff --git a/scripts/experiments/observe-powershell/CuCaptureTopology.cs b/scripts/experiments/observe-powershell/CuCaptureTopology.cs new file mode 100644 index 0000000..0c59929 --- /dev/null +++ b/scripts/experiments/observe-powershell/CuCaptureTopology.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.InteropServices; +using System.Text; +public static class CuCaptureNative { + [DllImport("user32.dll")] public static extern bool SetProcessDpiAwarenessContext(IntPtr value); + [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow(); + [DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint processId); + [DllImport("user32.dll", SetLastError=true)] public static extern IntPtr OpenInputDesktop(uint flags, bool inherit, uint access); + [DllImport("user32.dll")] public static extern bool CloseDesktop(IntPtr desktop); + [DllImport("user32.dll", SetLastError=true, CharSet=CharSet.Unicode)] public static extern bool GetUserObjectInformation(IntPtr handle, int index, StringBuilder value, int length, out int needed); + [DllImport("wtsapi32.dll", SetLastError=true)] public static extern bool WTSQuerySessionInformation(IntPtr server, int sessionId, int infoClass, out IntPtr buffer, out int bytesReturned); + [DllImport("wtsapi32.dll")] public static extern void WTSFreeMemory(IntPtr buffer); + [DllImport("user32.dll")] private static extern int GetSystemMetrics(int index); + private delegate bool MonitorCallback(IntPtr monitor, IntPtr hdc, ref NativeRect rectangle, IntPtr data); + [DllImport("user32.dll", SetLastError=true)] private static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr clip, MonitorCallback callback, IntPtr data); + [DllImport("user32.dll", EntryPoint="GetMonitorInfoW", CharSet=CharSet.Unicode, ExactSpelling=true, SetLastError=true)] private static extern bool GetMonitorInfo(IntPtr monitor, ref MonitorInfo info); + [StructLayout(LayoutKind.Sequential)] private struct NativeRect { public int left, top, right, bottom; } + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] private struct MonitorInfo { + public uint size; public NativeRect monitor; public NativeRect work; public uint flags; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] public string device; + } + public sealed class Bounds { public int X, Y, Width, Height; } + public sealed class Screen { public Bounds Bounds; public bool Primary; public string DeviceName; } + public static Bounds VirtualScreen() { + return new Bounds { X=GetSystemMetrics(76), Y=GetSystemMetrics(77), Width=GetSystemMetrics(78), Height=GetSystemMetrics(79) }; + } + public static Screen[] AllScreens() { + var screens=new List(); + Exception failure=null; + MonitorCallback callback=delegate(IntPtr monitor, IntPtr hdc, ref NativeRect rect, IntPtr data) { + try { + var info=new MonitorInfo(); info.size=(uint)Marshal.SizeOf(typeof(MonitorInfo)); + if(!GetMonitorInfo(monitor, ref info)) throw new Win32Exception(Marshal.GetLastWin32Error()); + if(screens.Count>=32) throw new InvalidOperationException("display_limit"); + screens.Add(new Screen { Bounds=new Bounds { X=info.monitor.left,Y=info.monitor.top,Width=checked(info.monitor.right-info.monitor.left),Height=checked(info.monitor.bottom-info.monitor.top) }, Primary=(info.flags&1)!=0,DeviceName=info.device }); + return true; + } catch(Exception error) { failure=error; return false; } + }; + bool success=EnumDisplayMonitors(IntPtr.Zero,IntPtr.Zero,callback,IntPtr.Zero); + GC.KeepAlive(callback); + if(failure!=null) throw failure; + if(!success||screens.Count==0) throw new Win32Exception(Marshal.GetLastWin32Error()); + return screens.ToArray(); + } +} diff --git a/scripts/experiments/observe-powershell/EmptyHelper.cs b/scripts/experiments/observe-powershell/EmptyHelper.cs new file mode 100644 index 0000000..95b4fa5 --- /dev/null +++ b/scripts/experiments/observe-powershell/EmptyHelper.cs @@ -0,0 +1,5 @@ +using System; +public static class EmptyHelper { + [STAThread] + public static int Main() { return 0; } +} diff --git a/scripts/experiments/observe-powershell/empty-helper.c b/scripts/experiments/observe-powershell/empty-helper.c new file mode 100644 index 0000000..78f2de1 --- /dev/null +++ b/scripts/experiments/observe-powershell/empty-helper.c @@ -0,0 +1 @@ +int main(void) { return 0; } diff --git a/scripts/experiments/observe-powershell/executable-startup.mjs b/scripts/experiments/observe-powershell/executable-startup.mjs new file mode 100644 index 0000000..39671ea --- /dev/null +++ b/scripts/experiments/observe-powershell/executable-startup.mjs @@ -0,0 +1,61 @@ +// Compare fresh process startup only. These programs do not capture pixels or validate the helper protocol. +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { existsSync, mkdirSync, statSync, writeFileSync } from "node:fs"; +import { dirname, isAbsolute, join, resolve } from "node:path"; +import { performance } from "node:perf_hooks"; +import { fileURLToPath, pathToFileURL } from "node:url"; +const here = dirname(fileURLToPath(import.meta.url)); +const repositoryRoot = resolve(here, "../../.."); +const [outputRoot, gcc, pwsh] = process.argv.slice(2); +if (![outputRoot, gcc, pwsh].every((value) => value && isAbsolute(value))) { + throw new Error("Usage: node scripts/experiments/observe-powershell/executable-startup.mjs NEW_ABSOLUTE_DIRECTORY ABSOLUTE_GCC ABSOLUTE_PWSH"); +} +if (existsSync(outputRoot)) throw new Error("Output directory already exists."); +const { stockPowerShellPath } = await import(pathToFileURL(join(repositoryRoot, "dist/test/support/controlled-window.js"))); +const stock = stockPowerShellPath(); +const compiler = resolve(dirname(stock), "../../../Microsoft.NET/Framework64/v4.0.30319/csc.exe"); +mkdirSync(outputRoot, { recursive: true }); +const managed = join(outputRoot, "empty-managed.exe"); +const native = join(outputRoot, "empty-native.exe"); +for (const [executable, args] of [ + [compiler, ["/nologo", "/target:exe", "/optimize+", "/platform:anycpu", `/out:${managed}`, join(here, "EmptyHelper.cs")]], + [gcc, ["-O2", "-s", "-static-libgcc", join(here, "empty-helper.c"), "-o", native]], +]) { + const build = spawnSync(executable, args, { encoding: "utf8", windowsHide: true, shell: false, timeout: 30_000 }); + assert.equal(build.status, 0, build.stdout + build.stderr); +} +const flags = ["-NoLogo", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", "exit 0"]; +const variants = [ + { name: "ps51", executable: stock, args: flags }, + { name: "ps7", executable: pwsh, args: flags }, + { name: "framework-exe", executable: managed, args: [] }, + { name: "native-exe", executable: native, args: [] }, + { name: "node", executable: process.execPath, args: ["-e", "process.exit(0)"] }, +]; +const result = { note: "Fresh process, warm filesystem caches. Empty programs only; no capture, PNG, protocol, archive, or validation. Concurrent game/background load is not controlled.", rounds: 20, binaries: { managedBytes: statSync(managed).size, nativeBytes: statSync(native).size }, samples: [] }; +const output = join(outputRoot, "results.json"); +for (let pair = 0; pair < result.rounds; pair++) { + const offset = pair % variants.length; + let order = [...variants.slice(offset), ...variants.slice(0, offset)]; + if (Math.floor(pair / variants.length) % 2) order = order.toReversed(); + for (const variant of order) { + const start = performance.now(); + const run = spawnSync(variant.executable, variant.args, { encoding: "utf8", windowsHide: true, shell: false, timeout: 15_000 }); + const totalMs = performance.now() - start; + assert.equal(run.status, 0, run.stderr); + assert.equal(run.stdout, ""); + assert.equal(run.stderr, ""); + result.samples.push({ pair, name: variant.name, totalMs }); + } + writeFileSync(output, `${JSON.stringify(result, null, 2)}\n`); +} +const median = (values) => { const sorted = values.toSorted((a, b) => a - b); return (sorted[9] + sorted[10]) / 2; }; +const times = (name) => result.samples.filter((s) => s.name === name).map((s) => s.totalMs); +result.medians = Object.fromEntries(variants.map((v) => [v.name, median(times(v.name))])); +result.comparisons = variants.slice(1).map((variant) => { + const saved = times("ps51").map((value, index) => value - times(variant.name)[index]); + return { baseline: "ps51", candidate: variant.name, pairedMedianSavedMs: median(saved), pairsWon: saved.filter((v) => v > 0).length }; +}); +writeFileSync(output, `${JSON.stringify(result, null, 2)}\n`); +console.log(JSON.stringify({ medians: result.medians, comparisons: result.comparisons, binaries: result.binaries, output })); diff --git a/scripts/experiments/observe-powershell/measure.mjs b/scripts/experiments/observe-powershell/measure.mjs new file mode 100644 index 0000000..2519666 --- /dev/null +++ b/scripts/experiments/observe-powershell/measure.mjs @@ -0,0 +1,108 @@ +// Research-only CLI matrix. Each row gets its own growing archive; desktop work stays serial. +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join, resolve } from "node:path"; +import { performance } from "node:perf_hooks"; +import { fileURLToPath, pathToFileURL } from "node:url"; +const repositoryRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../../.."); +const [manifestPath, output, roundText, ...selection] = process.argv.slice(2); +const fresh = selection.includes("--fresh"); +const names = selection.filter((name) => name !== "--fresh"); +const rounds = Number(roundText); +if (!manifestPath || !output || !Number.isSafeInteger(rounds) || rounds < 3 || rounds > 100 || names.length < 2 || new Set(names).size !== names.length) { + throw new Error("Usage: node scripts/experiments/observe-powershell/measure.mjs MANIFEST OUTPUT ROUNDS VARIANT VARIANT [...]"); +} +function parseJson(text, context) { + try { return JSON.parse(text); } + catch (cause) { throw new Error(`Invalid JSON in ${context}`, { cause }); } +} +const manifest = parseJson(readFileSync(manifestPath, "utf8"), manifestPath); +const variants = names.map((name) => { + const entry = manifest.variants.find((v) => v.name === name); + if (!entry) throw new Error(`Unknown variant: ${name}`); + return { ...entry }; +}); +const support = await import(pathToFileURL(join(manifest.fixtureRoot ?? repositoryRoot, "dist/test/support/controlled-window.js"))); +const { initializeWorkspace } = await import(pathToFileURL(join(repositoryRoot, "dist/src/workspace.js"))); +const result = { note: "Complete CLI wall time. Fixture/init/pixel checks excluded. Rotating then reversed order. Fresh mode uses a new initialized workspace for every sample, records failures and continues the finite schedule without retry; growing-history mode stops on failure.", fresh, manifest, rounds, names, samples: [] }; +const save = () => writeFileSync(output, `${JSON.stringify(result, null, 2)}\n`); +const median = (values) => { + const s = values.toSorted((a, b) => a - b); + return (s[Math.floor((s.length - 1) / 2)] + s[Math.floor(s.length / 2)]) / 2; +}; +let fixture; +try { + for (const variant of variants) { + variant.workspace = mkdtempSync(join(tmpdir(), "cu-runtime-benchmark-")); + initializeWorkspace(variant.workspace); + } + fixture = await support.startControlledWindowFixture(); + const rect = fixture.target; + result.region = rect; + const colors = support.deriveControlledPatternColors(fixture.token); + const pattern = support.readControlledPattern(); + for (let pair = 0; pair < rounds; pair++) { + const start = pair % variants.length; + let order = [...variants.slice(start), ...variants.slice(0, start)]; + if (Math.floor(pair / variants.length) % 2) order = order.toReversed(); + for (const variant of order) { + if (fresh) { + rmSync(variant.workspace, { recursive: true, force: true }); + variant.workspace = mkdtempSync(join(tmpdir(), "cu-runtime-benchmark-")); + initializeWorkspace(variant.workspace); + } + const before = performance.now(); + const execution = spawnSync(process.execPath, [join(variant.root, "dist/src/cli.js"), "observe", "benchmark", "--region", `pixel:${rect.x},${rect.y},${rect.width},${rect.height}`, "--json"], { + cwd: variant.workspace, encoding: "utf8", windowsHide: true, shell: false, timeout: 30_000, maxBuffer: 1_048_576, + }); + const sample = { pair, name: variant.name, totalMs: performance.now() - before, status: execution.status }; + result.samples.push(sample); + if (execution.status !== 0 || execution.stderr !== "") { + sample.error = execution.stderr + execution.stdout; + save(); + console.log(JSON.stringify(sample)); + if (fresh) continue; + throw new Error(sample.error); + } + const receipt = parseJson(execution.stdout, `${variant.name} observe receipt`); + assert.equal(receipt.kind, "cu.observe.result/v1"); + const bytes = readFileSync(join(variant.workspace, receipt.imagePath)); + const decoded = support.decodePngRgba(bytes); + assert.equal(decoded.width, rect.width); + assert.equal(decoded.height, rect.height); + for (const [i, point] of pattern.samples.entries()) { + assert.deepEqual(support.sampleRgb(decoded, point.x, point.y), colors.target[i]); + } + sample.imageBytes = bytes.length; + sample.pixelsVerified = true; + save(); + console.log(JSON.stringify(sample)); + } + } + assert.deepEqual(await fixture.snapshotAndClear(), { target: [], decoy: [] }); + const successes = (name) => result.samples.filter((s) => s.name === name && s.pixelsVerified); + result.medians = Object.fromEntries(names.map((name) => [name, successes(name).length ? median(successes(name).map((s) => s.totalMs)) : null])); + result.failures = Object.fromEntries(names.map((name) => [name, rounds - successes(name).length])); + result.comparisons = []; + for (let a = 0; a < names.length; a++) for (let b = a + 1; b < names.length; b++) { + const matched = successes(names[a]).flatMap((baseline) => { + const candidate = successes(names[b]).find((s) => s.pair === baseline.pair); + return candidate ? [{ baseline: baseline.totalMs, candidate: candidate.totalMs }] : []; + }); + const saved = matched.map((s) => s.baseline - s.candidate); + result.comparisons.push({ baseline: names[a], candidate: names[b], matchedPairs: saved.length, pairedMedianSavedMs: saved.length ? median(saved) : null, pairsWon: saved.filter((v) => v > 0).length, medianReduction: saved.length ? 1 - median(matched.map((s) => s.candidate)) / median(matched.map((s) => s.baseline)) : null }); + } + result.complete = true; + save(); + console.log(JSON.stringify({ medians: result.medians, comparisons: result.comparisons })); +} catch (error) { + result.complete = false; + result.error = String(error); + save(); + throw error; +} finally { + try { if (fixture) await fixture.stop(); } + finally { for (const variant of variants) if (variant.workspace) rmSync(variant.workspace, { recursive: true, force: true }); } +} diff --git a/scripts/experiments/observe-powershell/prepare.mjs b/scripts/experiments/observe-powershell/prepare.mjs new file mode 100644 index 0000000..1a3cbcc --- /dev/null +++ b/scripts/experiments/observe-powershell/prepare.mjs @@ -0,0 +1,88 @@ +// Research-only variants. Does not change the installed cu runtime or package assets. +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { createHash } from "node:crypto"; +import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; +import { dirname, isAbsolute, join, resolve } from "node:path"; +import { fileURLToPath, pathToFileURL } from "node:url"; + +const here = dirname(fileURLToPath(import.meta.url)); +const repositoryRoot = resolve(here, "../../.."); +const [destination, pwshArgument] = process.argv.slice(2); +if (!destination || !pwshArgument || !isAbsolute(destination) || !isAbsolute(pwshArgument)) { + throw new Error("Usage: node scripts/experiments/observe-powershell/prepare.mjs ABSOLUTE_NEW_DIRECTORY ABSOLUTE_PWSH_EXE"); +} +if (existsSync(destination)) throw new Error("The output directory must not already exist."); +if (process.platform !== "win32") throw new Error("Interactive Windows is required."); +const { stockPowerShellPath } = await import(pathToFileURL(join(repositoryRoot, "dist/test/support/controlled-window.js"))); +const stock = stockPowerShellPath(); +const systemRoot = resolve(dirname(stock), "../../.."); +const compiler = join(systemRoot, "Microsoft.NET/Framework64/v4.0.30319/csc.exe"); +for (const path of [compiler, pwshArgument, join(repositoryRoot, "dist/src/cli.js")]) { + if (!existsSync(path)) throw new Error(`Missing prerequisite: ${path}`); +} +const source = readFileSync(join(repositoryRoot, "dist/helper/windows-capture.ps1"), "utf8"); +const parent = readFileSync(join(repositoryRoot, "dist/src/windows-capture.js"), "utf8"); +function replaceOnce(text, before, after) { + assert.equal(text.split(before).length, 2, `Source changed; inspect the adaptation for ${before}`); + return text.replace(before, after); +} +const portable = replaceOnce(source, + "[AppDomain]::CurrentDomain.DefineDynamicAssembly($assemblyName, [Reflection.Emit.AssemblyBuilderAccess]::Run)", + "[Reflection.Emit.AssemblyBuilder]::DefineDynamicAssembly($assemblyName, [Reflection.Emit.AssemblyBuilderAccess]::Run)"); +mkdirSync(destination); +const assemblies = {}; +for (const stem of ["CuCaptureNative", "CuCaptureTopology"]) { + const output = join(destination, `${stem}.dll`); + const result = spawnSync(compiler, ["/nologo", "/target:library", "/optimize+", "/platform:anycpu", `/out:${output}`, join(here, `${stem}.cs`)], { + encoding: "utf8", windowsHide: true, shell: false, timeout: 30_000, + }); + assert.equal(result.status, 0, result.stdout + result.stderr); + assemblies[stem] = output; +} +const variants = []; +for (const [runtime, executable] of [["ps51", stock], ["ps7", pwshArgument]]) { + const modes = runtime === "ps51" ? ["current", "portable", "dll", "load", "dll-load", "dll-load-native"] : ["portable", "dll", "load", "dll-load", "dll-load-native"]; + for (const mode of modes) { + const name = `${runtime}-${mode}`; + const root = join(destination, name); + mkdirSync(root); + cpSync(join(repositoryRoot, "dist"), join(root, "dist"), { recursive: true }); + cpSync(join(repositoryRoot, "test/fixtures"), join(root, "test/fixtures"), { recursive: true }); + cpSync(join(repositoryRoot, "package.json"), join(root, "package.json")); + let helper = mode === "current" ? source : portable; + if (mode.includes("dll")) { + const start = helper.indexOf("function Initialize-CaptureNative {"); + const end = helper.indexOf("function Test-SessionConnected"); + assert.ok(start > 0 && end > start); + helper = helper.slice(0, start) + "function Initialize-CaptureNative {\n [void][Reflection.Assembly]::LoadFrom([IO.Path]::Combine($PSScriptRoot, 'CuCaptureNative.dll'))\n}\n\n" + helper.slice(end); + cpSync(assemblies[mode.endsWith("native") ? "CuCaptureTopology" : "CuCaptureNative"], join(root, "dist/helper/CuCaptureNative.dll")); + } + if (mode.includes("load")) { + for (const [assembly, token] of [["System.Windows.Forms", "b77a5c561934e089"], ["System.Drawing", "b03f5f7f11d50a3a"]]) { + helper = replaceOnce(helper, `Add-Type -AssemblyName ${assembly}`, `[void][Reflection.Assembly]::Load('${assembly}, Version=4.0.0.0, Culture=neutral, PublicKeyToken=${token}')`); + } + } + if (mode.endsWith("native")) { + helper = replaceOnce(helper, " [void][Reflection.Assembly]::Load('System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')", ""); + helper = replaceOnce(helper, "[System.Windows.Forms.SystemInformation]::VirtualScreen", "[CuCaptureNative]::VirtualScreen()"); + helper = replaceOnce(helper, "[System.Windows.Forms.Screen]::AllScreens", "[CuCaptureNative]::AllScreens()"); + } + writeFileSync(join(root, "dist/helper/windows-capture.ps1"), helper); + // Reconstruct the legacy dispatcher from the current native parent. The system-root + // resolution and every parent-side content/identity check stay identical. + let legacyParent = replaceOnce(parent, 'new URL("../helper/cu-capture.exe", import.meta.url)', 'new URL("../helper/windows-capture.ps1", import.meta.url)'); + const runtimeArgs = ["-NoLogo", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File"]; + legacyParent = replaceOnce(legacyParent, "spawnSync(helperPath, [], {", `spawnSync(${JSON.stringify(executable)}, [...${JSON.stringify(runtimeArgs)}, helperPath], {`); + writeFileSync(join(root, "dist/src/windows-capture.js"), legacyParent); + variants.push({ name, root, executable, mode, helperSha256: createHash("sha256").update(helper).digest("hex") }); + } +} +const manifest = { + note: "Experimental PowerShell built copies of the legacy capture endpoint. Production uses native capture. DLLs are managed AnyCPU assemblies compiled locally; no experiment binaries are checked in. Only capture/displays runtime changes, not input.", + createdAt: new Date().toISOString(), node: process.version, compiler, + sourceSha256: createHash("sha256").update(source).digest("hex"), + variants, +}; +writeFileSync(join(destination, "manifest.json"), `${JSON.stringify(manifest, null, 2)}\n`); +console.log(JSON.stringify(manifest)); diff --git a/scripts/experiments/observe-powershell/startup.mjs b/scripts/experiments/observe-powershell/startup.mjs new file mode 100644 index 0000000..fe4d25f --- /dev/null +++ b/scripts/experiments/observe-powershell/startup.mjs @@ -0,0 +1,24 @@ +// Fresh-process startup floor; no desktop capture and no helper script execution. +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { writeFileSync } from "node:fs"; +import { performance } from "node:perf_hooks"; +const [output, stock, pwsh] = process.argv.slice(2); +if (!output || !stock || !pwsh) throw new Error("Usage: node scripts/experiments/observe-powershell/startup.mjs OUTPUT STOCK_EXE PWSH_EXE"); +const variants = [{ name: "ps51", executable: stock }, { name: "ps7", executable: pwsh }]; +const samples = []; +for (let pair = 0; pair < 16; pair++) { + for (const variant of pair % 2 ? variants.toReversed() : variants) { + const start = performance.now(); + const run = spawnSync(variant.executable, ["-NoLogo", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", "exit 0"], { windowsHide: true, shell: false, encoding: "utf8", timeout: 30_000 }); + const totalMs = performance.now() - start; + assert.equal(run.status, 0, run.stderr); + assert.equal(run.stdout, ""); + assert.equal(run.stderr, ""); + samples.push({ pair, name: variant.name, totalMs }); + } +} +const median = (a) => { const s = a.toSorted((a, b) => a - b); return (s[7] + s[8]) / 2; }; +const summary = Object.fromEntries(variants.map(({ name }) => [name, median(samples.filter((s) => s.name === name).map((s) => s.totalMs))])); +writeFileSync(output, `${JSON.stringify({ note: "Fresh process, warm OS caches, exit 0; game/background load retained.", summary, samples }, null, 2)}\n`); +console.log(JSON.stringify(summary)); diff --git a/scripts/experiments/observe-powershell/verify.mjs b/scripts/experiments/observe-powershell/verify.mjs new file mode 100644 index 0000000..5eca135 --- /dev/null +++ b/scripts/experiments/observe-powershell/verify.mjs @@ -0,0 +1,31 @@ +// Run the existing helper behavior tests against experimental runtimes. The fixture itself stays on stock PowerShell. +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { readFileSync, writeFileSync } from "node:fs"; +import { join } from "node:path"; +const [manifestPath, ...names] = process.argv.slice(2); +if (!manifestPath || !names.length) throw new Error("Usage: node scripts/experiments/observe-powershell/verify.mjs MANIFEST VARIANT [...]"); +function parseJson(text, context) { + try { return JSON.parse(text); } + catch (cause) { throw new Error(`Invalid JSON in ${context}`, { cause }); } +} +const manifest = parseJson(readFileSync(manifestPath, "utf8"), manifestPath); +let expectedDisplay; +for (const name of names) { + const variant = manifest.variants.find((v) => v.name === name); + assert.ok(variant, `Unknown variant ${name}`); + const original = readFileSync(join(variant.root, "dist/test/windows-capture-helper.test.js"), "utf8"); + assert.ok(original.includes("stockPowerShellPath()")); + const testPath = join(variant.root, "dist/test/windows-capture-runtime.test.js"); + writeFileSync(testPath, original.replaceAll("stockPowerShellPath()", JSON.stringify(variant.executable))); + const result = spawnSync(process.execPath, ["--test", "--test-concurrency=1", testPath], { encoding: "utf8", windowsHide: true, shell: false, timeout: 120_000, maxBuffer: 1_048_576 }); + writeFileSync(join(variant.root, "verification.log"), result.stdout + result.stderr); + console.log(JSON.stringify({ name, status: result.status, log: join(variant.root, "verification.log") })); + assert.equal(result.status, 0, result.stdout + result.stderr); + const query = spawnSync(process.execPath, [join(variant.root, "dist/src/cli.js"), "displays", "--json"], { encoding: "utf8", windowsHide: true, shell: false, timeout: 30_000 }); + assert.equal(query.status, 0, query.stderr + query.stdout); + const display = parseJson(query.stdout, `${name} displays receipt`); + if (expectedDisplay) assert.deepEqual(display, expectedDisplay); + else expectedDisplay = display; +} +console.log(JSON.stringify({ displayReceiptsMatch: true, variants: names })); diff --git a/skills/cu-automation/SKILL.md b/skills/cu-automation/SKILL.md index f56e9b1..c694d15 100644 --- a/skills/cu-automation/SKILL.md +++ b/skills/cu-automation/SKILL.md @@ -1,140 +1,122 @@ --- name: cu-automation -description: Automate Windows desktop and GUI applications via cu CLI using evidence-bound observations and finite action plans. Use when controlling desktop apps, clicking UI elements, typing into Windows windows, or automating desktop workflows. +description: Automate Windows desktop and GUI applications via cu CLI with evidence-bound observations and finite action plans. Use for desktop screenshots, clicks, typing, and GUI workflows. In Pi, use codemode to capture and optionally return the screenshot as model-visible image content in one call. --- -# cu Automation Skill - -Automate Windows GUI tasks safely using the `cu` CLI. `cu` is an evidence-bound computer-use interface that executes finite pointer and keyboard plans against fresh desktop observations. - -## Core Rules & Invariants - -1. **Strict Evidence-Bound Authority (Single-Use Lifecycle)**: - - Input requires an active, unconsumed `observationId`. - - **One observation = exactly one `act`**: Any `act` command (whether `completed` or `checkpoint`) immediately consumes that `observationId`. - - Never reuse an `observationId`. For the next action, either use the new `checkpoint.observationId` returned in the receipt, or run `cu observe` again. -2. **Normalized Coordinates (`0..999`)**: - - Coordinates (`{"x": 0..999, "y": 0..999}`) are relative to the *observed image crop*, with origin `(0,0)` at the top-left and `(999,999)` at the bottom-right. Never use physical screen pixels in action files. -3. **Always Pass `--json`**: - - All commands must include `--json` for predictable, parseable machine receipts. -4. **Automatic Checkpoint Segmentation**: - - `cu` automatically ends an action segment at visual decision boundaries (before a second coordinate action, or after `drag`, `wheel`, focus keys like `Tab`/`Enter`/arrows, or `chord`). - - When a boundary is hit, `cu` executes only the safe prefix, captures a new observation, and returns `outcome: "checkpoint"`. **The unexecuted trailing actions are discarded and never run automatically.** -5. **No Blind Replay**: - - On exit 4 (`partial`) or exit 5 (`indeterminate`), never replay the old plan. Run `cu observe` anew to inspect the real desktop state before deciding the next step. -6. **Workspace Directory Stickiness & Run IDs**: - - All state is stored locally under `.cu/` in the current working directory. Keep your shell cwd consistent. - - `run_id` must use lowercase ASCII letters, digits, dots, underscores, and hyphens (`[a-z0-9._-]+`), e.g., `work-1`. - ---- - -## Standard Loop (Observe -> Inspect -> Plan -> Act -> Verify) - -``` -[cu init] -> [cu observe] -> [Inspect PNG] -> [Write action.json] -> [cu act] -> [Check Outcome / Loop] -``` - -### Step 1: Initialize Workspace (Once per task) -```powershell -cu init --json -``` - -### Step 2: Observe Target Region -`cu` requires an explicit capture selector — either a region or one or more whole displays. There is no implicit current-desktop target. - -Region capture syntax: `--region pixel:,,,` (L, T, W, H): -```powershell -cu observe work-1 --region pixel:100,100,1200,800 --json -``` - -Full-screen capture syntax: `--full-screen `, mutually exclusive with `--region`/`--display`. Copy the display IDs verbatim from `cu displays --json` (comma-separated for multiple screens, e.g. `dsp_0123456789abcdef0123456789abcdef`): -```powershell -cu displays --json -cu observe work-1 --full-screen dsp_0123456789abcdef0123456789abcdef --json -``` - -*(Optional: Run `cu displays --json` for multi-monitor topology inspection or `--display ` region binding).* - -Receipt: -```json -{ - "kind": "cu.observe.result/v1", - "runId": "work-1", - "observationId": "obs_0123456789abcdef0123456789abcdef", - "imagePath": ".cu/work-1/captures/obs_0123456789abcdef0123456789abcdef.png", - "coordinateSpace": "normalized_999_top_left", - "expiresAt": "2026-07-23T00:05:00.000Z", - "actionable": true -} -``` -*Note*: Observations expire after 300 seconds by default (`expiresAt`). To change the lifetime, pass `--ttl ` (minimum `1`; `unlimited` records `expiresAt: null`, so the observation never expires by time): -```powershell -cu observe work-1 --region pixel:100,100,1200,800 --ttl 60 --json -``` -A checkpoint observation inherits the TTL of the observation it replaced. Act within the window, or re-run `observe` if expired — `observation_expired` receipts carry `retryable: true`, and retrying with a fresh observation is the intended recovery. - -### Step 3: Inspect the Screenshot & Locate Coordinates -Inspect `imagePath` using your image inspection tool. Calculate target coordinates directly from this image: -- Top-left: `{"x": 0, "y": 0}` -- Center: `{"x": 500, "y": 500}` -- Bottom-right: `{"x": 999, "y": 999}` - -### Step 4: Plan & Execute Actions -Write the plan to a UTF-8 (no BOM) JSON file, then execute: -```json -// action.json -{ - "kind": "cu.action/v1", - "observationId": "obs_0123456789abcdef0123456789abcdef", - "coordinateSpace": "normalized_999_top_left", - "actions": [ - { "kind": "click", "at": { "x": 450, "y": 320 } }, - { "kind": "type_text", "text": "Hello World" } - ] -} -``` -```powershell -cu act work-1 --action-file action.json --json -``` - -> **Best Practice**: Keep plans micro-batched (1 coordinate action + subsequent text/key). Because a second click or a focus key cuts a checkpoint and discards trailing actions, planning one interaction at a time prevents discarded steps. - -### Step 5: Check Outcome & Branch - -Read the JSON result: -- **`outcome: "completed"`**: All actions executed. Re-observe if further actions are needed. -- **`outcome: "checkpoint"`**: Truncated at a boundary. Receipt contains: - ```json - { - "kind": "cu.act.result/v1", - "outcome": "checkpoint", - "checkpoint": { - "observationId": "obs_fedcba9876543210fedcba9876543210", - "imagePath": ".cu/work-1/captures/obs_fedcba9876543210fedcba9876543210.png", - "actionable": true - } - } - ``` - **Use `checkpoint.observationId` and inspect `checkpoint.imagePath` for your next plan.** Do not replay the old plan. The checkpoint observation inherits the replaced observation's TTL and capture selection (region rectangle or full-screen set), so coordinates stay relative to `checkpoint.imagePath` in the same `0..999` space. - ---- - -## Exit Code & Failure Recovery Matrix - -| Exit Code | Classification | What Happened | Action to Take | -| :---: | :--- | :--- | :--- | -| **0** | Success / Checkpoint | Execution succeeded or reached a clean checkpoint. | Proceed to next step, or consume `checkpoint.observationId`. | -| **2** | Action File Error | Bad JSON, unrecognized keys, invalid key names, or coordinates out of range. | No desktop effect. Fix `action.json` syntax and retry with the **same** `observationId`. | -| **3** | Blocked | Action blocked before any input was emitted (e.g. `observation_expired`, `observation_consumed`, `run_busy`). | Inspect error receipt `retryable` field. If `retryable: true`, run `cu observe` again and retry with the new `observationId`. If `run_busy`, check `cu status work-1 --json`. | -| **4** | Partial Effect | Some input was emitted, but execution was interrupted or could not be proven. | **DO NOT replay the plan.** Run `cu observe` to inspect current desktop state. | -| **5** | Indeterminate | State could not be proven after input emission. | **DO NOT replay the plan.** Run `cu observe` to inspect current desktop state. | - ---- - -## Diagnosis & Cleanup - -- **Diagnose run state**: Run `cu status work-1 --json` to inspect lifecycle, locks, and active observation validity without side effects. -- **Cleanup when task is complete**: Captures consume quota in `.cu//captures/`. Run `cu clearall work-1 --json` only after the entire task is finished (it invalidates the current live observation). - -For the action file JSON schema and key whitelist, see: -- [references/action-file-spec.md](references/action-file-spec.md) +# cu Automation + +Use `cu` for Windows desktop observation and bounded pointer/keyboard input. + +## Pi: choose whether to see the image before running the command + +**When `codemode` is available, use it for the visual loop.** Do not default to a +standalone `bash` call followed by another model turn just to read its screenshot. +Before the first visual call, read [Pi codemode recipes](references/pi-codemode.md) +and use its receipt-handling recipe for both `observe` and `act` checkpoints. + +Choose the delivery mode yourself from the task; no user confirmation is needed: + +| Intent | Delivery | One codemode call | +| --- | --- | --- | +| Locate a control, understand layout, or visually verify a result | `view = "image"` | `bash` → parse receipt → `read` PNG → `image(shot)` | +| Save evidence or pass the image to programmatic processing | `view = "none"` | `bash` → return receipt; omit `image()` | +| Inspect an already captured observation | `view = "image"` | `read` its PNG → `image(shot)`; do not recapture | + +`view` is a local recipe variable, **not a cu CLI flag**. A path printed by `bash` +does not show its pixels to the model. Inside codemode, `read()` returns an image +block; only `image(shot)` exposes that block as visual output. Do not print base64 +with `text()`, `console.log()`, or `return`. + +If the next decision needs visual evidence, choose `image` now. If you chose +`none` and later need to see the capture, read the existing PNG first. An unseen +image does not support guessed coordinates. Capturing still publishes a new +observation and supersedes the previous one, regardless of delivery mode. + +If codemode is unavailable, use standalone `bash`, then the host's image-reading +tool when needed. If a call fails or moves to a background task, determine whether +it already executed before continuing. **An image-delivery failure never justifies +replaying `act` or taking another capture automatically.** + +## Setup and scope + +- Keep one explicit workspace and run ID throughout the task. State lives under + that workspace's `.cu/`; parent and child directories do not share it. +- Initialize once: `cu init --json`. Use `--json` on every cu command. +- Observe an explicitly chosen region: + `cu observe work-1 --region pixel:100,100,800,600 --json`. + The rectangle is left, top, width, height in virtual-screen pixels; replace it + with the task's actual target bounds. +- Use `cu displays --json` for display geometry and exact IDs. Bind a region with + `--display `, or capture whole displays with + `--full-screen `. Copy IDs verbatim from `displays`; + `--full-screen` is mutually exclusive with `--region` and `--display`. A bare + `observe ` has no implicit desktop target. Check `cu help observe --json` + if the installed release's capabilities are uncertain. +- The default observation TTL is 300 seconds. Use + `--ttl ` to change it; the minimum is `1`. + `unlimited` records `expiresAt: null`, removing time-based expiry only. + `observation_expired` is retryable by obtaining a fresh observation and planning + from it; do not reuse stale coordinates. +- Run IDs use lowercase ASCII letters, digits, dots, underscores, and hyphens; + empty IDs, `.`, `..`, and path separators are rejected. + +## Efficient observe → plan → act loop + +1. **Observe and deliver.** In one codemode call, run `observe`, print its compact + receipt, and optionally show its PNG using the recipe. Retain the returned + `observationId`, `imagePath`, coordinate space, and expiry. +2. **Plan from the current evidence.** Coordinates are integers `0..999`, relative + to the observed image, top-left origin. For image pixel `(px, py)` in a `W × H` + image, use `round(px * 999 / (W - 1))` and `round(py * 999 / (H - 1))` when the + dimensions exceed one. Never copy screen pixels into an action plan or treat a + separately cropped preview's coordinates as coordinates of the original image. +3. **Write and execute together.** Once the plan is known, a single codemode call + can write its UTF-8 JSON action file, await that write, execute `act`, and deliver + any checkpoint image. Use `tools.write` for JSON rather than shell interpolation; + do not log typed text. See [action format](references/action-file-spec.md). +4. **Use the result.** A `checkpoint` already contains the next observation and + PNG: deliver `receipt.checkpoint.imagePath` in the **same** codemode call and + plan against `receipt.checkpoint.observationId`. Do not add an `observe` merely + to obtain an image that the checkpoint already captured. A `completed` result + has no fresh image; observe again only if another action or verification needs it. + Checkpoints inherit the replaced observation's TTL and capture selection (region + or full-screen set); coordinates remain relative to the new checkpoint image. +5. **Verify the task result.** Input emission is not proof of application success. + Inspect the relevant final state; do not add redundant status/history reads + after a sufficient result. If a checkpoint catches a transitional UI, obtain + fresh evidence after the expected change before choosing another target. + +### Plan only the segment cu can execute + +- Prefer a direct `click` over `pointer_move` followed by `click`: both carry + coordinates, so the second one would be cut off. +- Batch one coordinate action with already-determined text/key actions, such as + `click → type_text → Enter`. Do not batch across a decision that needs new pixels. +- The second coordinate action checkpoints **before** execution. Drag, wheel, + every chord, and focus/navigation keys checkpoint **after** execution. The exact + key list is in [action format](references/action-file-spec.md). +- The unexecuted tail is discarded. Never submit a long speculative plan or replay + its tail automatically after a checkpoint. +- Serialize desktop operations. Different run IDs do not isolate the physical + desktop; `Promise.all()` is not appropriate for competing observe/act calls. + +## Observation authority and failures + +A successful `act` consumes its input observation, whether its outcome is +`completed` or `checkpoint`. Partial or indeterminate effects must not be replayed. +Only the current, unexpired, unconsumed observation can authorize another action; +reading an image does not renew its lifetime or authority. + +| Result | Next step | +| --- | --- | +| Exit 0, `checkpoint` | Inspect the returned checkpoint when needed; use its new ID. | +| Exit 0, `completed` | Verify or re-observe if further work needs fresh evidence. | +| Exit 2, invalid action file | No desktop effect. Correct the file; reuse the ID only if still current and valid. | +| Exit 3, blocked | Inspect the error code. Expired/consumed evidence requires observation; `run_busy` requires coordination/status, not a replay loop. | +| Exit 4 or 5, partial/indeterminate | Never replay. Observe the real current state and decide a new plan. | +| Shell background task or missing completion | Follow that task to completion before parsing a receipt or issuing another desktop command. | +| PNG delivery failed after a receipt | Read that same PNG again if available; preserve the action outcome. | + +Use `cu status work-1 --json` for diagnosis. History images are diagnostic-only +and cannot authorize input. Use `cu clearall work-1 --json` only when the task is +finished and evidence is no longer needed; it invalidates the current observation. diff --git a/skills/cu-automation/references/action-file-spec.md b/skills/cu-automation/references/action-file-spec.md index 0ad6982..1fba9bd 100644 --- a/skills/cu-automation/references/action-file-spec.md +++ b/skills/cu-automation/references/action-file-spec.md @@ -53,7 +53,9 @@ Validation rules: { "kind": "key", "key": "Enter" } ``` - `key`: valid portable key name from the whitelist below. -- *Note*: Focus keys (`Tab`, `Enter`, `Escape`, `Arrow*`) trigger a checkpoint boundary after execution. +- *Note*: `Enter`, `NumpadEnter`, `Tab`, `Escape`, `ContextMenu`, `Insert`, + `Delete`, `Home`, `End`, `PageUp`, `PageDown`, arrow keys, and `F1..F24` trigger a + checkpoint after execution. A chord also always triggers a checkpoint. ### 4. `chord` (Simultaneous Key Combinations) ```json @@ -89,15 +91,21 @@ Validation rules: - *Note*: Always triggers a checkpoint boundary after execution. ### 7. `pointer_move` (Hover / Reposition) + ```json { "kind": "pointer_move", "to": { "x": 500, "y": 500 } } ``` +- A `pointer_move` counts as a coordinate action. Prefer a direct `click` over + `pointer_move` followed by `click`; the second coordinate action would be discarded + at a checkpoint. + --- ## Rare Variant: `sequence` (Modifier-Held Actions) Used rarely, only when holding a modifier (such as Ctrl) during a click or drag: + ```json { "kind": "sequence", @@ -108,6 +116,7 @@ Used rarely, only when holding a modifier (such as Ctrl) during a click or drag: ] } ``` + - Must contain exactly 1 coordinate action (`click`, `drag`, `pointer_move`, `wheel`). - Modifiers allowed for `key_down`/`key_up`: `"Control"`, `"Alt"`, `"Shift"`. - **Strict balance**: Every `key_down` must have a matching `key_up` in reverse order. No keys may remain held. diff --git a/skills/cu-automation/references/pi-codemode.md b/skills/cu-automation/references/pi-codemode.md new file mode 100644 index 0000000..57794f1 --- /dev/null +++ b/skills/cu-automation/references/pi-codemode.md @@ -0,0 +1,143 @@ +# Pi codemode recipes + +Use these inside the **codemode tool**, not as JavaScript passed to bash. Codemode +has `tools`, `text()`, `image()`, and `store()`; it has no Node.js `process`, `fs`, +`require`, or `import`. Resolve paths from an explicit workspace. + +## Observe and optionally show the image in one call + +Adapt `workspace`, `runId`, the region, and `view` before calling. Keep the explicit +workspace identical in the PowerShell command and image-path resolution. The +example expects `cu init --json` to have succeeded there already. + +The current Pi shell extension can return a string; stock Pi can return an object +with `output` and `exit_code`. This recipe handles both. Check the active tool's +schema for its timeout fields; `timeout` below is in seconds. A host may still +background a command, so the recipe detects that result rather than rerunning it. + +```js +const workspace = "D:/cu-work"; +const runId = "work-1"; +const view = "image"; // "none" saves/returns the receipt without showing pixels +const quotePS = (s) => "'" + s.replaceAll("'", "''") + "'"; +const result = await tools.bash({ + command: `Set-Location -LiteralPath ${quotePS(workspace)} -ErrorAction Stop; cu observe ${quotePS(runId)} --region pixel:100,100,800,600 --json`, + background: false, + timeout: 30, +}); +const output = typeof result === "string" ? result : result.output; +if (typeof output !== "string") throw new Error("Missing shell output; inspect this call before continuing."); +if (output.includes("background task created")) { + text(output); // Follow the returned task ID using the host's background tools. + exit(); // Do not issue observe/act again while that task is unfinished. +} +let receipt; +try { + receipt = JSON.parse(output.trim()); +} catch { + text("No complete JSON receipt; inspect this command's result before another desktop operation."); + exit(); +} +text(receipt); +store(`cu:${workspace}:${runId}:receipt`, receipt); +if (receipt.kind === "cu.error/v1") exit(); +if (typeof result !== "string" && result.exit_code !== 0) exit(); +const observation = receipt.kind === "cu.observe.result/v1" + ? receipt + : receipt.kind === "cu.act.result/v1" && receipt.outcome === "checkpoint" + ? receipt.checkpoint + : undefined; +if (view === "none" || !observation) exit(); +const id = observation.observationId; +if (!/^[a-z0-9._-]+$/.test(runId) || runId === "." || runId === ".." || + !/^obs_[a-f0-9]{32}$/.test(id) || receipt.runId !== runId || + observation.imagePath !== `.cu/${runId}/captures/${id}.png`) { + throw new Error("Unexpected observation path or identity; inspect the receipt."); +} +const path = `${workspace.replace(/\/$/, "")}/${observation.imagePath}`; +try { + const shot = await tools.read({ path, offset: 1, limit: 1 }); + if (typeof shot === "string" || shot.type !== "image") { + throw new Error("Expected an image block."); + } + if (shot.note) text(shot.note); + image(shot); +} catch { + text({ imageDelivery: "failed", imagePath: path, + next: "Read this same image if still available. Do not replay the command." }); +} +``` + +`image(shot)` is the operation that makes the screenshot visible to the model. +`text(shot)` would dump base64 as text. Calling `read()` inside codemode without +`image()` does not expose its pixels to the parent model. A terminal image preview +or Markdown image path is not a substitute for an image content block. + +The shell may throw on a nonzero exit instead of returning an object. In that +case, inspect the tool error and follow the skill's failure table. A failed +codemode call does not roll back any completed capture, file write, or input. + +## Act and show the checkpoint in the same call + +Use the recipe above with the `bash` command changed to: + +```js +command: `Set-Location -LiteralPath ${quotePS(workspace)} -ErrorAction Stop; cu act ${quotePS(runId)} --action-file action.json --json`, +``` + +Its receipt handler already recognizes `receipt.checkpoint`. Keep it in that +same codemode call. `view = "image"` shows a returned checkpoint; `view = "none"` +returns only its receipt. A `completed` action has no checkpoint image and this +handler deliberately stops there. + +When the plan is ready, eliminate a separate write-only turn by inserting an +awaited write **before** `tools.bash` in that same recipe: + +```js +// plan was chosen from current evidence; never invent its observationId. +await tools.write({ + path: `${workspace}/action.json`, + content: JSON.stringify(plan), +}); +``` + +Use a distinct action-file name for unrelated tasks. Do not print the plan or +raw typed text. Do not interpolate JSON into shell code. Never run the write and +act in parallel. `--action-file -` also exists for callers with a proper stdin +channel; the file path avoids PowerShell encoding/quoting mistakes here. + +## Look at an existing capture without taking a new one + +Use the exact absolute path resolved from a successful receipt: + +```js +const shot = await tools.read({ + path: "D:/cu-work/.cu/work-1/captures/obs_0123456789abcdef0123456789abcdef.png", + offset: 1, + limit: 1, +}); +if (typeof shot === "string" || shot.type !== "image") throw new Error("Expected image"); +if (shot.note) text(shot.note); +image(shot); +``` + +The ID above is a placeholder. Reading the image does not create a new observation, +extend its TTL, or restore consumed authority. If it has expired, been superseded, +been consumed, or been removed, obtain fresh evidence before another action. + +## Efficiency boundaries + +- Select `none` for collection, archiving, or processing where the model does not + need pixels. Processing code may read bytes or pass an image to another tool + without calling `image()`. +- Select `image` whenever the next model decision needs to interpret the screenshot. + This avoids another model turn devoted only to opening the file. +- Keep observation → delivery and act → checkpoint delivery within their respective + codemode calls. The next visual decision belongs to the next model turn; codemode + cannot reason over a new screenshot in the middle of a running script. +- Reuse a checkpoint image; do not recapture solely because the first call returned + a path. Never use `history` to revive action authority. +- If the shell auto-backgrounds, continue the original task, retrieve its completed + receipt, and then deliver that PNG. Do not parse a task notice as a cu receipt. +- Prefer the host's `read` image conversion; keep its resize notes. Any additional + crop requires a known mapping back to the original observation's coordinates. diff --git a/src/helper/native/.clang-format b/src/helper/native/.clang-format new file mode 100644 index 0000000..6a34181 --- /dev/null +++ b/src/helper/native/.clang-format @@ -0,0 +1,3 @@ +BasedOnStyle: LLVM +ColumnLimit: 100 +SortIncludes: Never diff --git a/src/helper/native/CMakeLists.txt b/src/helper/native/CMakeLists.txt new file mode 100644 index 0000000..e673373 --- /dev/null +++ b/src/helper/native/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.20) +project(cu_capture LANGUAGES CXX) +add_executable(cu-capture capture.cpp) +option(CU_BUILD_TESTS "Build desktop-free native core checks" OFF) +if(CU_BUILD_TESTS) + add_executable(cu-capture-core ../../../test/native/capture-core.cpp) +endif() +set(cu_targets cu-capture) +if(CU_BUILD_TESTS) + list(APPEND cu_targets cu-capture-core) +endif() +foreach(target IN LISTS cu_targets) + target_compile_features(${target} PRIVATE cxx_std_17) + target_compile_definitions(${target} PRIVATE UNICODE _UNICODE _WIN32_WINNT=0x0A00) + target_link_libraries(${target} PRIVATE user32 gdi32 gdiplus ole32 bcrypt wtsapi32) + if(MSVC) + set_property(TARGET ${target} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + target_compile_options(${target} PRIVATE /W4 /utf-8) + else() + target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic -Werror) + target_link_options(${target} PRIVATE -static -static-libgcc -static-libstdc++) + endif() +endforeach() diff --git a/src/helper/native/capture.cpp b/src/helper/native/capture.cpp new file mode 100644 index 0000000..4b3570f --- /dev/null +++ b/src/helper/native/capture.cpp @@ -0,0 +1,561 @@ +// Command-scoped capture endpoint. No workspace writes and no input emission. +#define WIN32_LEAN_AND_MEAN +#define NOMINMAX +// Windows SDK headers below require windows.h to be included first. +#include +#include +#include +#include +#include +#include "vendor/json.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace cu { +using Json = nlohmann::ordered_json; +struct Failure {}; +void require(bool valid) { + if (!valid) + throw Failure{}; +} +constexpr std::size_t maxRequest = 65536; +constexpr std::size_t maxImage = 67108864; +constexpr int64_t intMin = -2147483648LL, intMax = 2147483647LL; + +bool keys(const Json &value, std::initializer_list names) { + if (!value.is_object() || value.size() != names.size()) + return false; + return std::all_of(names.begin(), names.end(), + [&](const char *name) { return value.contains(name); }); +} +bool integer(const Json &value, int64_t low, int64_t high) { + if (!value.is_number_integer()) + return false; + if (value.is_number_unsigned()) + return value.get() <= static_cast(high) && + (low <= 0 || value.get() >= static_cast(low)); + const auto n = value.get(); + return n >= low && n <= high; +} +bool identifier(const Json &value, const std::string &prefix) { + if (!value.is_string()) + return false; + const auto &s = value.get_ref(); + return s.size() == prefix.size() + 32 && s.compare(0, prefix.size(), prefix) == 0 && + std::all_of(s.begin() + prefix.size(), s.end(), + [](char c) { return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'); }); +} +bool regionShape(const Json &s) { + if (keys(s, {"kind", "left", "top", "right", "bottom"}) && s["kind"] == "normalized") { + for (auto key : {"left", "top", "right", "bottom"}) + if (!integer(s[key], 0, 999)) + return false; + return s["left"].get() <= s["right"].get() && + s["top"].get() <= s["bottom"].get(); + } + return keys(s, {"kind", "left", "top", "width", "height"}) && s["kind"] == "pixel" && + integer(s["left"], intMin, intMax) && integer(s["top"], intMin, intMax) && + integer(s["width"], 1, 4096) && integer(s["height"], 1, 4096); +} +bool selectorShape(const Json &s) { + if (regionShape(s)) + return true; + if (keys(s, {"kind", "displayId", "region"}) && s["kind"] == "display_region") + return identifier(s["displayId"], "dsp_") && regionShape(s["region"]); + if (!keys(s, {"kind", "displayIds"}) || s["kind"] != "full_screen" || + !s["displayIds"].is_array() || s["displayIds"].empty() || s["displayIds"].size() > 32) + return false; + std::set seen; + for (const auto &id : s["displayIds"]) + if (!identifier(id, "dsp_") || !seen.insert(id.get()).second) + return false; + return true; +} +Json parseRequest(const std::string &bytes) { + require(!bytes.empty() && bytes.size() <= maxRequest && bytes.back() == '\n'); + // Reject duplicates before ordered_json can collapse them. All numbers are admitted below. + std::vector> objectKeys; + auto callback = [&](int depth, Json::parse_event_t event, Json &value) { + require(depth <= 16); + if (event == Json::parse_event_t::object_start) + objectKeys.emplace_back(); + if (event == Json::parse_event_t::key) + require(!objectKeys.empty() && objectKeys.back().insert(value.get()).second); + if (event == Json::parse_event_t::object_end) + objectKeys.pop_back(); + return true; + }; + auto request = Json::parse(bytes, callback); + require(request.is_object() && request.contains("requestId") && + identifier(request["requestId"], "req_")); + const bool display = + keys(request, {"kind", "requestId"}) && request["kind"] == "cu.windows-display.request/v1"; + const bool capture = keys(request, {"kind", "requestId", "destinationPath", "selector"}) && + request["kind"] == "cu.windows-capture.request/v1" && + request["destinationPath"].is_string() && selectorShape(request["selector"]); + require(display || capture); + require(request.dump() + "\n" == bytes); + return request; +} +std::wstring wide(const std::string &s) { + require(!s.empty() && s.find('\0') == std::string::npos && s.size() <= 65536); + const int count = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), + static_cast(s.size()), nullptr, 0); + require(count > 0); + std::wstring result(count, L'\0'); + require(MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), static_cast(s.size()), + result.data(), count) == count); + return result; +} +std::string utf8(const std::wstring &s) { + const int count = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s.data(), + static_cast(s.size()), nullptr, 0, nullptr, nullptr); + require(count > 0); + std::string result(count, '\0'); + require(WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s.data(), static_cast(s.size()), + result.data(), count, nullptr, nullptr) == count); + return result; +} +std::string sha256(const unsigned char *bytes, std::size_t size) { + BCRYPT_ALG_HANDLE algorithm = nullptr; + BCRYPT_HASH_HANDLE hash = nullptr; + require(size <= maxImage); + try { + require(BCryptOpenAlgorithmProvider(&algorithm, BCRYPT_SHA256_ALGORITHM, nullptr, 0) == 0); + require(BCryptCreateHash(algorithm, &hash, nullptr, 0, nullptr, 0, 0) == 0); + require(BCryptHashData(hash, const_cast(bytes), static_cast(size), 0) == 0); + std::array digest{}; + require(BCryptFinishHash(hash, digest.data(), static_cast(digest.size()), 0) == 0); + BCryptDestroyHash(hash); + hash = nullptr; + BCryptCloseAlgorithmProvider(algorithm, 0); + algorithm = nullptr; + const char *hex = "0123456789abcdef"; + std::string result; + for (auto b : digest) { + result += hex[b >> 4]; + result += hex[b & 15]; + } + return result; + } catch (...) { + if (hash) + BCryptDestroyHash(hash); + if (algorithm) + BCryptCloseAlgorithmProvider(algorithm, 0); + throw; + } +} +std::string hashJson(const Json &value) { + const auto s = value.dump(); + return sha256(reinterpret_cast(s.data()), s.size()); +} +struct Rect { + int64_t x, y, width, height; +}; +Json rectJson(const Rect &r) { + return {{"x", r.x}, {"y", r.y}, {"width", r.width}, {"height", r.height}}; +} +Rect rect(const Json &r) { + require(r.is_object() && r.contains("x") && r.contains("y") && r.contains("width") && + r.contains("height")); + require(integer(r["x"], intMin, intMax) && integer(r["y"], intMin, intMax) && + integer(r["width"], 1, intMax) && integer(r["height"], 1, intMax)); + Rect result{r["x"].get(), r["y"].get(), r["width"].get(), + r["height"].get()}; + require(result.x + result.width <= intMax && result.y + result.height <= intMax); + return result; +} +bool contains(const Rect &a, const Rect &b) { + return b.x >= a.x && b.y >= a.y && b.x + b.width <= a.x + a.width && + b.y + b.height <= a.y + a.height; +} +void validateTopology(const Json &snapshot, bool distinct) { + const auto virtualRect = rect(snapshot.at("virtualScreen")); + const auto &monitors = snapshot.at("monitors"); + require(monitors.is_array() && !monitors.empty() && monitors.size() <= 32); + std::set placements; + int primaries = 0; + for (const auto &m : monitors) { + require(keys(m, {"x", "y", "width", "height", "primary"}) && m["primary"].is_boolean()); + const auto r = rect(m); + require(contains(virtualRect, r)); + const bool inserted = placements.insert(rectJson(r).dump()).second; + require(!distinct || inserted); + if (m["primary"].get()) + ++primaries; + } + require(primaries == 1); +} +std::string displayId(const Json &snapshot, std::size_t index) { + const auto fingerprint = hashJson( + Json{{"virtualScreen", snapshot["virtualScreen"]}, {"monitors", snapshot["monitors"]}}); + return "dsp_" + hashJson(Json{{"kind", "cu.display-id/v1"}, + {"topologyFingerprint", fingerprint}, + {"index", index}}) + .substr(0, 32); +} +Rect resolveSelector(const Json &selector, const Json &snapshot) { + require(selectorShape(selector)); + const auto v = rect(snapshot.at("virtualScreen")); + const std::string kind = selector["kind"].get(); + if (kind == "display_region" || kind == "full_screen") { + validateTopology(snapshot, true); + const auto &monitors = snapshot["monitors"]; + auto find = [&](const Json &id) { + for (std::size_t i = 0; i < monitors.size(); ++i) + if (displayId(snapshot, i) == id) + return rect(monitors[i]); + throw Failure{}; + }; + if (kind == "display_region") { + const auto r = resolveSelector(selector["region"], snapshot); + require(contains(find(selector["displayId"]), r)); + return r; + } + Rect r = find(selector["displayIds"][0]); + int64_t right = r.x + r.width, bottom = r.y + r.height; + for (const auto &id : selector["displayIds"]) { + const auto m = find(id); + r.x = std::min(r.x, m.x); + r.y = std::min(r.y, m.y); + right = std::max(right, m.x + m.width); + bottom = std::max(bottom, m.y + m.height); + } + r.width = right - r.x; + r.height = bottom - r.y; + require(r.width <= 32768 && r.height <= 32768); + return r; + } + Rect r{}; + if (kind == "pixel") + r = {selector["left"].get(), selector["top"].get(), + selector["width"].get(), selector["height"].get()}; + else { + const int64_t left = selector["left"].get() * (v.width - 1) / 999, + top = selector["top"].get() * (v.height - 1) / 999; + const int64_t right = std::min( + v.width, (selector["right"].get() * (v.width - 1) + 998) / 999 + 1), + bottom = std::min( + v.height, + (selector["bottom"].get() * (v.height - 1) + 998) / 999 + 1); + r = {v.x + left, v.y + top, right - left, bottom - top}; + } + require(r.width <= 4096 && r.height <= 4096 && contains(v, r) && !contains(r, v)); + return r; +} +struct Monitor { + Rect bounds; + bool primary; + std::wstring name; +}; +struct MonitorEnumeration { + std::vector monitors; + bool failed = false; +}; +BOOL CALLBACK enumerateMonitor(HMONITOR monitor, HDC, LPRECT, LPARAM context) noexcept { + auto &state = *reinterpret_cast(context); + try { + MONITORINFOEXW info{}; + info.cbSize = sizeof(info); + require(GetMonitorInfoW(monitor, &info) != 0 && state.monitors.size() < 32); + state.monitors.push_back({{info.rcMonitor.left, info.rcMonitor.top, + int64_t(info.rcMonitor.right) - info.rcMonitor.left, + int64_t(info.rcMonitor.bottom) - info.rcMonitor.top}, + (info.dwFlags & MONITORINFOF_PRIMARY) != 0, + info.szDevice}); + return TRUE; + } catch (...) { + state.failed = true; + return FALSE; + } +} +Json snapshot(bool distinct) { + DWORD session = 0; + require(ProcessIdToSessionId(GetCurrentProcessId(), &session) != 0 && session <= intMax); + LPWSTR buffer = nullptr; + DWORD count = 0; + const bool queried = WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, session, + WTSConnectState, &buffer, &count) != 0; + bool connected = false; + if (queried && buffer && count >= sizeof(WTS_CONNECTSTATE_CLASS)) + connected = *reinterpret_cast(buffer) == WTSActive; + if (buffer) + WTSFreeMemory(buffer); + require(connected); + USEROBJECTFLAGS flags{}; + DWORD needed = 0; + require(GetUserObjectInformationW(GetProcessWindowStation(), UOI_FLAGS, &flags, sizeof(flags), + &needed) != 0 && + (flags.dwFlags & WSF_VISIBLE)); + HDESK desktop = OpenInputDesktop(0, FALSE, DESKTOP_READOBJECTS); + require(desktop != nullptr); + std::wstring desktopName; + try { + GetUserObjectInformationW(desktop, UOI_NAME, nullptr, 0, &needed); + require(needed > 2 && needed <= 1024 && needed % sizeof(wchar_t) == 0); + std::vector name(needed / sizeof(wchar_t), L'\0'); + require(GetUserObjectInformationW(desktop, UOI_NAME, name.data(), needed, &needed) != 0 && + name.back() == L'\0'); + desktopName = name.data(); + } catch (...) { + CloseDesktop(desktop); + throw; + } + require(CloseDesktop(desktop) != 0 && desktopName == L"Default"); + Rect virtualRect{GetSystemMetrics(SM_XVIRTUALSCREEN), GetSystemMetrics(SM_YVIRTUALSCREEN), + GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN)}; + MonitorEnumeration enumeration; + require(EnumDisplayMonitors(nullptr, nullptr, enumerateMonitor, + reinterpret_cast(&enumeration)) != 0 && + !enumeration.failed); + auto &monitors = enumeration.monitors; + std::sort(monitors.begin(), monitors.end(), [](const Monitor &a, const Monitor &b) { + if (a.bounds.x != b.bounds.x) + return a.bounds.x < b.bounds.x; + if (a.bounds.y != b.bounds.y) + return a.bounds.y < b.bounds.y; + return a.name < b.name; + }); + Json list = Json::array(); + for (const auto &monitor : monitors) { + auto m = rectJson(monitor.bounds); + m["primary"] = monitor.primary; + list.push_back(m); + } + const HWND window = GetForegroundWindow(); + DWORD pid = 0; + GetWindowThreadProcessId(window, &pid); + require(pid <= intMax); + char handle[19]{}; + std::snprintf(handle, sizeof(handle), "0x%016llx", + static_cast(reinterpret_cast(window))); + Json value{{"virtualScreen", rectJson(virtualRect)}, + {"monitors", list}, + {"desktop", + {{"interactive", true}, + {"connected", true}, + {"kind", "default"}, + {"sessionId", session}, + {"desktopName", "Default"}}}, + {"foreground", {{"windowHandle", handle}, {"processId", pid}}}}; + validateTopology(value, distinct); + return value; +} +bool sameEnvironment(Json before, Json after, bool displayOnly) { + if (displayOnly) { + before.erase("foreground"); + after.erase("foreground"); + } + return before == after; +} +std::wstring fullPath(const std::wstring &raw) { + require(!raw.empty() && raw.find(L'\0') == std::wstring::npos && raw.size() < 32768); + DWORD count = GetFullPathNameW(raw.c_str(), 0, nullptr, nullptr); + require(count > 0 && count <= 32768); + std::vector out(count); + DWORD written = GetFullPathNameW(raw.c_str(), count, out.data(), nullptr); + require(written > 0 && written < count); + return std::wstring(out.data(), written); +} +std::wstring destinationPath(const std::string &destination) { + DWORD count = GetEnvironmentVariableW(L"TEMP", nullptr, 0); + require(count > 1 && count <= 32768); + std::vector temp(count); + require(GetEnvironmentVariableW(L"TEMP", temp.data(), count) == count - 1); + auto root = fullPath(temp.data()); + while (root.size() > 3 && root.back() == L'\\') + root.pop_back(); + const auto path = fullPath(wide(destination)); + const auto separator = path.find_last_of(L"\\/"); + require(separator != std::wstring::npos); + const auto parent = path.substr(0, separator), leaf = path.substr(separator + 1); + require(CompareStringOrdinal(parent.data(), static_cast(parent.size()), root.data(), + static_cast(root.size()), TRUE) == CSTR_EQUAL); + require(leaf.size() > 4 && leaf.substr(leaf.size() - 4) == L".png" && + leaf.find_first_of(L":*?<>|\"") == std::wstring::npos); + require(GetFileAttributesW(path.c_str()) == INVALID_FILE_ATTRIBUTES && + GetLastError() == ERROR_FILE_NOT_FOUND); + return path; +} +class OwnedFile { + HANDLE handle_ = INVALID_HANDLE_VALUE; + bool published_ = false; + +public: + explicit OwnedFile(const std::wstring &path) { + handle_ = CreateFileW(path.c_str(), GENERIC_READ | GENERIC_WRITE | DELETE, 0, nullptr, + CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr); + require(handle_ != INVALID_HANDLE_VALUE); + } + OwnedFile(const OwnedFile &) = delete; + OwnedFile &operator=(const OwnedFile &) = delete; + ~OwnedFile() { + if (handle_ != INVALID_HANDLE_VALUE) { + if (!published_) { + FILE_DISPOSITION_INFO deletion{TRUE}; + SetFileInformationByHandle(handle_, FileDispositionInfo, &deletion, sizeof(deletion)); + } + CloseHandle(handle_); + } + } + void write(const unsigned char *data, std::size_t size) { + require(size > 0 && size <= maxImage); + DWORD written = 0; + require(WriteFile(handle_, data, static_cast(size), &written, nullptr) != 0 && + written == size); + require(FlushFileBuffers(handle_) != 0); + } + std::vector read() { + LARGE_INTEGER size{}, zero{}; + require(GetFileSizeEx(handle_, &size) != 0 && size.QuadPart > 0 && + size.QuadPart <= int64_t(maxImage)); + require(SetFilePointerEx(handle_, zero, nullptr, FILE_BEGIN) != 0); + std::vector result(static_cast(size.QuadPart)); + DWORD count = 0; + require(ReadFile(handle_, result.data(), static_cast(result.size()), &count, nullptr) != + 0 && + count == result.size()); + return result; + } + void publish() { published_ = true; } +}; +class GdiSession { + ULONG_PTR token_ = 0; + +public: + GdiSession() { + Gdiplus::GdiplusStartupInput input; + require(Gdiplus::GdiplusStartup(&token_, &input, nullptr) == Gdiplus::Ok); + } + ~GdiSession() { + if (token_) + Gdiplus::GdiplusShutdown(token_); + } +}; +struct StreamRelease { + void operator()(IStream *value) const { + if (value) + value->Release(); + } +}; +std::vector capturePng(const Rect &rect) { + GdiSession session; + Gdiplus::Bitmap bitmap(static_cast(rect.width), static_cast(rect.height), + PixelFormat24bppRGB); + require(bitmap.GetLastStatus() == Gdiplus::Ok); + { + Gdiplus::Graphics graphics(&bitmap); + require(graphics.GetLastStatus() == Gdiplus::Ok); + HDC target = graphics.GetHDC(); + require(target != nullptr); + HDC source = GetDC(nullptr); + const bool copied = + source && BitBlt(target, 0, 0, static_cast(rect.width), static_cast(rect.height), + source, static_cast(rect.x), static_cast(rect.y), SRCCOPY) != 0; + const bool released = !source || ReleaseDC(nullptr, source) != 0; + graphics.ReleaseHDC(target); + require(copied && released && graphics.GetLastStatus() == Gdiplus::Ok); + } + IStream *raw = nullptr; + require(CreateStreamOnHGlobal(nullptr, TRUE, &raw) == S_OK); + std::unique_ptr stream(raw); + const CLSID pngEncoder{ + 0x557cf406, 0x1a04, 0x11d3, {0x9a, 0x73, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e}}; + require(bitmap.Save(stream.get(), &pngEncoder, nullptr) == Gdiplus::Ok); + STATSTG stat{}; + require(stream->Stat(&stat, STATFLAG_NONAME) == S_OK && stat.cbSize.QuadPart > 0 && + stat.cbSize.QuadPart <= maxImage); + LARGE_INTEGER zero{}; + require(stream->Seek(zero, STREAM_SEEK_SET, nullptr) == S_OK); + std::vector bytes(static_cast(stat.cbSize.QuadPart)); + ULONG read = 0; + require(stream->Read(bytes.data(), static_cast(bytes.size()), &read) == S_OK && + read == bytes.size()); + return bytes; +} +std::string readRequest() { + std::string value; + std::array chunk{}; + DWORD count = 0; + HANDLE input = GetStdHandle(STD_INPUT_HANDLE); + for (;;) { + const BOOL ok = + ReadFile(input, chunk.data(), static_cast(chunk.size()), &count, nullptr); + if (!ok) { + require(GetLastError() == ERROR_BROKEN_PIPE); + break; + } + if (count == 0) + break; + require(value.size() + count <= maxRequest); + value.append(chunk.data(), count); + } + return value; +} +void output(const Json &result) { + const auto bytes = result.dump() + "\n"; + require(bytes.size() <= 65536); + DWORD written = 0; + require(WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), bytes.data(), static_cast(bytes.size()), + &written, nullptr) != 0 && + written == bytes.size()); +} +int execute() { + require(SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) != 0); + const auto request = parseRequest(readRequest()); + if (request["kind"] == "cu.windows-display.request/v1") { + const auto before = snapshot(true), after = snapshot(true); + require(sameEnvironment(before, after, true)); + output(Json{{"kind", "cu.windows-display.result/v1"}, + {"requestId", request["requestId"]}, + {"virtualScreen", before["virtualScreen"]}, + {"monitors", before["monitors"]}}); + return 0; + } + const auto destination = destinationPath(request["destinationPath"].get()); + const auto &selector = request["selector"]; + const bool distinct = selector["kind"] == "display_region" || selector["kind"] == "full_screen"; + const auto before = snapshot(distinct); + const auto region = resolveSelector(selector, before); + const auto image = capturePng(region); + OwnedFile file(destination); + file.write(image.data(), image.size()); + const auto after = snapshot(distinct); + require(sameEnvironment(before, after, false)); + const auto persisted = file.read(); + output(Json{{"kind", "cu.windows-capture.result/v1"}, + {"requestId", request["requestId"]}, + {"destinationPath", utf8(destination)}, + {"sourceRectPx", rectJson(region)}, + {"virtualScreen", before["virtualScreen"]}, + {"monitors", before["monitors"]}, + {"desktop", before["desktop"]}, + {"foreground", before["foreground"]}, + {"image", + {{"sha256", sha256(persisted.data(), persisted.size())}, + {"byteLength", persisted.size()}, + {"width", region.width}, + {"height", region.height}}}}); + file.publish(); + return 0; +} +} // namespace cu +#ifndef CU_CAPTURE_TEST +int main() { + try { + return cu::execute(); + } catch (...) { + const char error[] = "capture_failed\n"; + DWORD written = 0; + WriteFile(GetStdHandle(STD_ERROR_HANDLE), error, sizeof(error) - 1, &written, nullptr); + return 3; + } +} +#endif diff --git a/src/helper/native/vendor/LICENSE.nlohmann-json b/src/helper/native/vendor/LICENSE.nlohmann-json new file mode 100644 index 0000000..b5a1027 --- /dev/null +++ b/src/helper/native/vendor/LICENSE.nlohmann-json @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2013-2025 Niels Lohmann + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/helper/native/vendor/README.md b/src/helper/native/vendor/README.md new file mode 100644 index 0000000..f5fa448 --- /dev/null +++ b/src/helper/native/vendor/README.md @@ -0,0 +1,12 @@ +# Native capture dependency + +`json.hpp` is the unmodified single-header distribution of **nlohmann/json v3.12.0**: + +- Source: https://raw.githubusercontent.com/nlohmann/json/v3.12.0/single_include/nlohmann/json.hpp +- SHA-256: `aaf127c04cb31c406e5b04a63f1ae89369fccde6d8fa7cdda1ed4f32dfc5de63` +- License: [MIT](LICENSE.nlohmann-json), copied into the packaged runtime. + +The helper uses ordered JSON for protocol serialization and hashing, rejects duplicate +keys in a parse callback, bounds request bytes/depth, admits exact request shapes and +integer ranges, then requires byte-for-byte canonical serialization plus one LF. +The header is compiled into the executable; it is not a runtime DLL or network dependency. diff --git a/src/helper/native/vendor/json.hpp b/src/helper/native/vendor/json.hpp new file mode 100644 index 0000000..82d69f7 --- /dev/null +++ b/src/helper/native/vendor/json.hpp @@ -0,0 +1,25526 @@ +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-License-Identifier: MIT + +/****************************************************************************\ + * Note on documentation: The source files contain links to the online * + * documentation of the public API at https://json.nlohmann.me. This URL * + * contains the most recent documentation and should also be applicable to * + * previous versions; documentation for deprecated functions is not * + * removed, but marked deprecated. See "Generate documentation" section in * + * file docs/README.md. * +\****************************************************************************/ + +#ifndef INCLUDE_NLOHMANN_JSON_HPP_ +#define INCLUDE_NLOHMANN_JSON_HPP_ + +#include // all_of, find, for_each +#include // nullptr_t, ptrdiff_t, size_t +#include // hash, less +#include // initializer_list +#ifndef JSON_NO_IO + #include // istream, ostream +#endif // JSON_NO_IO +#include // random_access_iterator_tag +#include // unique_ptr +#include // string, stoi, to_string +#include // declval, forward, move, pair, swap +#include // vector + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// This file contains all macro definitions affecting or depending on the ABI + +#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK + #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH) + #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 12 || NLOHMANN_JSON_VERSION_PATCH != 0 + #warning "Already included a different version of the library!" + #endif + #endif +#endif + +#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum) +#define NLOHMANN_JSON_VERSION_MINOR 12 // NOLINT(modernize-macro-to-enum) +#define NLOHMANN_JSON_VERSION_PATCH 0 // NOLINT(modernize-macro-to-enum) + +#ifndef JSON_DIAGNOSTICS + #define JSON_DIAGNOSTICS 0 +#endif + +#ifndef JSON_DIAGNOSTIC_POSITIONS + #define JSON_DIAGNOSTIC_POSITIONS 0 +#endif + +#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON + #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 +#endif + +#if JSON_DIAGNOSTICS + #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag +#else + #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS +#endif + +#if JSON_DIAGNOSTIC_POSITIONS + #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS _dp +#else + #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS +#endif + +#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON + #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp +#else + #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON +#endif + +#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION + #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0 +#endif + +// Construct the namespace ABI tags component +#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c) json_abi ## a ## b ## c +#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b, c) \ + NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b, c) + +#define NLOHMANN_JSON_ABI_TAGS \ + NLOHMANN_JSON_ABI_TAGS_CONCAT( \ + NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ + NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON, \ + NLOHMANN_JSON_ABI_TAG_DIAGNOSTIC_POSITIONS) + +// Construct the namespace version component +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \ + _v ## major ## _ ## minor ## _ ## patch +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \ + NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) + +#if NLOHMANN_JSON_NAMESPACE_NO_VERSION +#define NLOHMANN_JSON_NAMESPACE_VERSION +#else +#define NLOHMANN_JSON_NAMESPACE_VERSION \ + NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \ + NLOHMANN_JSON_VERSION_MINOR, \ + NLOHMANN_JSON_VERSION_PATCH) +#endif + +// Combine namespace components +#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b +#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \ + NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) + +#ifndef NLOHMANN_JSON_NAMESPACE +#define NLOHMANN_JSON_NAMESPACE \ + nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \ + NLOHMANN_JSON_ABI_TAGS, \ + NLOHMANN_JSON_NAMESPACE_VERSION) +#endif + +#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN +#define NLOHMANN_JSON_NAMESPACE_BEGIN \ + namespace nlohmann \ + { \ + inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \ + NLOHMANN_JSON_ABI_TAGS, \ + NLOHMANN_JSON_NAMESPACE_VERSION) \ + { +#endif + +#ifndef NLOHMANN_JSON_NAMESPACE_END +#define NLOHMANN_JSON_NAMESPACE_END \ + } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ + } // namespace nlohmann +#endif + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include // transform +#include // array +#include // forward_list +#include // inserter, front_inserter, end +#include // map +#ifdef JSON_HAS_CPP_17 + #include // optional +#endif +#include // string +#include // tuple, make_tuple +#include // is_arithmetic, is_same, is_enum, underlying_type, is_convertible +#include // unordered_map +#include // pair, declval +#include // valarray + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include // nullptr_t +#include // exception +#if JSON_DIAGNOSTICS + #include // accumulate +#endif +#include // runtime_error +#include // to_string +#include // vector + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include // array +#include // size_t +#include // uint8_t +#include // string + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include // declval, pair +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +template struct make_void +{ + using type = void; +}; +template using void_t = typename make_void::type; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +// https://en.cppreference.com/w/cpp/experimental/is_detected +struct nonesuch +{ + nonesuch() = delete; + ~nonesuch() = delete; + nonesuch(nonesuch const&) = delete; + nonesuch(nonesuch const&&) = delete; + void operator=(nonesuch const&) = delete; + void operator=(nonesuch&&) = delete; +}; + +template class Op, + class... Args> +struct detector +{ + using value_t = std::false_type; + using type = Default; +}; + +template class Op, class... Args> +struct detector>, Op, Args...> +{ + using value_t = std::true_type; + using type = Op; +}; + +template class Op, class... Args> +using is_detected = typename detector::value_t; + +template class Op, class... Args> +struct is_detected_lazy : is_detected { }; + +template class Op, class... Args> +using detected_t = typename detector::type; + +template class Op, class... Args> +using detected_or = detector; + +template class Op, class... Args> +using detected_or_t = typename detected_or::type; + +template class Op, class... Args> +using is_detected_exact = std::is_same>; + +template class Op, class... Args> +using is_detected_convertible = + std::is_convertible, To>; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + +// #include + + +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-FileCopyrightText: 2016 - 2021 Evan Nemerson +// SPDX-License-Identifier: MIT + +/* Hedley - https://nemequ.github.io/hedley + * Created by Evan Nemerson + */ + +#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15) +#if defined(JSON_HEDLEY_VERSION) + #undef JSON_HEDLEY_VERSION +#endif +#define JSON_HEDLEY_VERSION 15 + +#if defined(JSON_HEDLEY_STRINGIFY_EX) + #undef JSON_HEDLEY_STRINGIFY_EX +#endif +#define JSON_HEDLEY_STRINGIFY_EX(x) #x + +#if defined(JSON_HEDLEY_STRINGIFY) + #undef JSON_HEDLEY_STRINGIFY +#endif +#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x) + +#if defined(JSON_HEDLEY_CONCAT_EX) + #undef JSON_HEDLEY_CONCAT_EX +#endif +#define JSON_HEDLEY_CONCAT_EX(a,b) a##b + +#if defined(JSON_HEDLEY_CONCAT) + #undef JSON_HEDLEY_CONCAT +#endif +#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) + +#if defined(JSON_HEDLEY_CONCAT3_EX) + #undef JSON_HEDLEY_CONCAT3_EX +#endif +#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c + +#if defined(JSON_HEDLEY_CONCAT3) + #undef JSON_HEDLEY_CONCAT3 +#endif +#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c) + +#if defined(JSON_HEDLEY_VERSION_ENCODE) + #undef JSON_HEDLEY_VERSION_ENCODE +#endif +#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) + +#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR) + #undef JSON_HEDLEY_VERSION_DECODE_MAJOR +#endif +#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) + +#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR) + #undef JSON_HEDLEY_VERSION_DECODE_MINOR +#endif +#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) + +#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION) + #undef JSON_HEDLEY_VERSION_DECODE_REVISION +#endif +#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) + +#if defined(JSON_HEDLEY_GNUC_VERSION) + #undef JSON_HEDLEY_GNUC_VERSION +#endif +#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) + #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) +#elif defined(__GNUC__) + #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) +#endif + +#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK) + #undef JSON_HEDLEY_GNUC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_GNUC_VERSION) + #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_MSVC_VERSION) + #undef JSON_HEDLEY_MSVC_VERSION +#endif +#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) +#elif defined(_MSC_FULL_VER) && !defined(__ICL) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) +#elif defined(_MSC_VER) && !defined(__ICL) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) +#endif + +#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) + #undef JSON_HEDLEY_MSVC_VERSION_CHECK +#endif +#if !defined(JSON_HEDLEY_MSVC_VERSION) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) +#elif defined(_MSC_VER) && (_MSC_VER >= 1400) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) +#elif defined(_MSC_VER) && (_MSC_VER >= 1200) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) +#else + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) +#endif + +#if defined(JSON_HEDLEY_INTEL_VERSION) + #undef JSON_HEDLEY_INTEL_VERSION +#endif +#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL) + #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) +#elif defined(__INTEL_COMPILER) && !defined(__ICL) + #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) +#endif + +#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK) + #undef JSON_HEDLEY_INTEL_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_INTEL_VERSION) + #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_INTEL_CL_VERSION) + #undef JSON_HEDLEY_INTEL_CL_VERSION +#endif +#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL) + #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0) +#endif + +#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK) + #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_INTEL_CL_VERSION) + #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_PGI_VERSION) + #undef JSON_HEDLEY_PGI_VERSION +#endif +#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) + #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) +#endif + +#if defined(JSON_HEDLEY_PGI_VERSION_CHECK) + #undef JSON_HEDLEY_PGI_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_PGI_VERSION) + #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_SUNPRO_VERSION) + #undef JSON_HEDLEY_SUNPRO_VERSION +#endif +#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) +#elif defined(__SUNPRO_C) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) +#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) +#elif defined(__SUNPRO_CC) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) +#endif + +#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK) + #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_SUNPRO_VERSION) + #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) + #undef JSON_HEDLEY_EMSCRIPTEN_VERSION +#endif +#if defined(__EMSCRIPTEN__) + #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) +#endif + +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) + #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) + #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_ARM_VERSION) + #undef JSON_HEDLEY_ARM_VERSION +#endif +#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) + #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) +#elif defined(__CC_ARM) && defined(__ARMCC_VERSION) + #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) +#endif + +#if defined(JSON_HEDLEY_ARM_VERSION_CHECK) + #undef JSON_HEDLEY_ARM_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_ARM_VERSION) + #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_IBM_VERSION) + #undef JSON_HEDLEY_IBM_VERSION +#endif +#if defined(__ibmxl__) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) +#elif defined(__xlC__) && defined(__xlC_ver__) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) +#elif defined(__xlC__) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) +#endif + +#if defined(JSON_HEDLEY_IBM_VERSION_CHECK) + #undef JSON_HEDLEY_IBM_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_IBM_VERSION) + #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_VERSION) + #undef JSON_HEDLEY_TI_VERSION +#endif +#if \ + defined(__TI_COMPILER_VERSION__) && \ + ( \ + defined(__TMS470__) || defined(__TI_ARM__) || \ + defined(__MSP430__) || \ + defined(__TMS320C2000__) \ + ) +#if (__TI_COMPILER_VERSION__ >= 16000000) + #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif +#endif + +#if defined(JSON_HEDLEY_TI_VERSION_CHECK) + #undef JSON_HEDLEY_TI_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_VERSION) + #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CL2000_VERSION) + #undef JSON_HEDLEY_TI_CL2000_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__) + #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CL2000_VERSION) + #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CL430_VERSION) + #undef JSON_HEDLEY_TI_CL430_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__) + #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CL430_VERSION) + #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) + #undef JSON_HEDLEY_TI_ARMCL_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__)) + #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK) + #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) + #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CL6X_VERSION) + #undef JSON_HEDLEY_TI_CL6X_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__) + #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CL6X_VERSION) + #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CL7X_VERSION) + #undef JSON_HEDLEY_TI_CL7X_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__) + #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CL7X_VERSION) + #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) + #undef JSON_HEDLEY_TI_CLPRU_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__) + #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK) + #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) + #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_CRAY_VERSION) + #undef JSON_HEDLEY_CRAY_VERSION +#endif +#if defined(_CRAYC) + #if defined(_RELEASE_PATCHLEVEL) + #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) + #else + #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) + #endif +#endif + +#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK) + #undef JSON_HEDLEY_CRAY_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_CRAY_VERSION) + #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_IAR_VERSION) + #undef JSON_HEDLEY_IAR_VERSION +#endif +#if defined(__IAR_SYSTEMS_ICC__) + #if __VER__ > 1000 + #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) + #else + #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0) + #endif +#endif + +#if defined(JSON_HEDLEY_IAR_VERSION_CHECK) + #undef JSON_HEDLEY_IAR_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_IAR_VERSION) + #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_TINYC_VERSION) + #undef JSON_HEDLEY_TINYC_VERSION +#endif +#if defined(__TINYC__) + #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) +#endif + +#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK) + #undef JSON_HEDLEY_TINYC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_TINYC_VERSION) + #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_DMC_VERSION) + #undef JSON_HEDLEY_DMC_VERSION +#endif +#if defined(__DMC__) + #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) +#endif + +#if defined(JSON_HEDLEY_DMC_VERSION_CHECK) + #undef JSON_HEDLEY_DMC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_DMC_VERSION) + #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_COMPCERT_VERSION) + #undef JSON_HEDLEY_COMPCERT_VERSION +#endif +#if defined(__COMPCERT_VERSION__) + #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) +#endif + +#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) + #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_COMPCERT_VERSION) + #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_PELLES_VERSION) + #undef JSON_HEDLEY_PELLES_VERSION +#endif +#if defined(__POCC__) + #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) +#endif + +#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK) + #undef JSON_HEDLEY_PELLES_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_PELLES_VERSION) + #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_MCST_LCC_VERSION) + #undef JSON_HEDLEY_MCST_LCC_VERSION +#endif +#if defined(__LCC__) && defined(__LCC_MINOR__) + #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__) +#endif + +#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK) + #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_MCST_LCC_VERSION) + #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_GCC_VERSION) + #undef JSON_HEDLEY_GCC_VERSION +#endif +#if \ + defined(JSON_HEDLEY_GNUC_VERSION) && \ + !defined(__clang__) && \ + !defined(JSON_HEDLEY_INTEL_VERSION) && \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_ARM_VERSION) && \ + !defined(JSON_HEDLEY_CRAY_VERSION) && \ + !defined(JSON_HEDLEY_TI_VERSION) && \ + !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ + !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ + !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ + !defined(__COMPCERT__) && \ + !defined(JSON_HEDLEY_MCST_LCC_VERSION) + #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION +#endif + +#if defined(JSON_HEDLEY_GCC_VERSION_CHECK) + #undef JSON_HEDLEY_GCC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_GCC_VERSION) + #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(JSON_HEDLEY_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_ATTRIBUTE +#endif +#if \ + defined(__has_attribute) && \ + ( \ + (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \ + ) +# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) +#else +# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) + #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) +#else + #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) + #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) +#else + #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE +#endif +#if \ + defined(__has_cpp_attribute) && \ + defined(__cplusplus) && \ + (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) +#else + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) +#endif + +#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS) + #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS +#endif +#if !defined(__cplusplus) || !defined(__has_cpp_attribute) + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) +#elif \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_IAR_VERSION) && \ + (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ + (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0)) + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) +#else + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) + #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) +#else + #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) + #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) +#else + #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_BUILTIN) + #undef JSON_HEDLEY_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) +#else + #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN) + #undef JSON_HEDLEY_GNUC_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) +#else + #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN) + #undef JSON_HEDLEY_GCC_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) +#else + #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_FEATURE) + #undef JSON_HEDLEY_HAS_FEATURE +#endif +#if defined(__has_feature) + #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) +#else + #define JSON_HEDLEY_HAS_FEATURE(feature) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE) + #undef JSON_HEDLEY_GNUC_HAS_FEATURE +#endif +#if defined(__has_feature) + #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) +#else + #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_FEATURE) + #undef JSON_HEDLEY_GCC_HAS_FEATURE +#endif +#if defined(__has_feature) + #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) +#else + #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_EXTENSION) + #undef JSON_HEDLEY_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) +#else + #define JSON_HEDLEY_HAS_EXTENSION(extension) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION) + #undef JSON_HEDLEY_GNUC_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) +#else + #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION) + #undef JSON_HEDLEY_GCC_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) +#else + #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) +#else + #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) +#else + #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) +#else + #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_HAS_WARNING) + #undef JSON_HEDLEY_HAS_WARNING +#endif +#if defined(__has_warning) + #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) +#else + #define JSON_HEDLEY_HAS_WARNING(warning) (0) +#endif + +#if defined(JSON_HEDLEY_GNUC_HAS_WARNING) + #undef JSON_HEDLEY_GNUC_HAS_WARNING +#endif +#if defined(__has_warning) + #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) +#else + #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_GCC_HAS_WARNING) + #undef JSON_HEDLEY_GCC_HAS_WARNING +#endif +#if defined(__has_warning) + #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) +#else + #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ + defined(__clang__) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) + #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_PRAGMA(value) __pragma(value) +#else + #define JSON_HEDLEY_PRAGMA(value) +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) + #undef JSON_HEDLEY_DIAGNOSTIC_PUSH +#endif +#if defined(JSON_HEDLEY_DIAGNOSTIC_POP) + #undef JSON_HEDLEY_DIAGNOSTIC_POP +#endif +#if defined(__clang__) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) + #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) +#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#else + #define JSON_HEDLEY_DIAGNOSTIC_PUSH + #define JSON_HEDLEY_DIAGNOSTIC_POP +#endif + +/* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for + HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ +#endif +#if defined(__cplusplus) +# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") +# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") +# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions") +# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ + _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ + _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \ + xpr \ + JSON_HEDLEY_DIAGNOSTIC_POP +# else +# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ + _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ + xpr \ + JSON_HEDLEY_DIAGNOSTIC_POP +# endif +# else +# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ + xpr \ + JSON_HEDLEY_DIAGNOSTIC_POP +# endif +# endif +#endif +#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x +#endif + +#if defined(JSON_HEDLEY_CONST_CAST) + #undef JSON_HEDLEY_CONST_CAST +#endif +#if defined(__cplusplus) +# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) +#elif \ + JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ + ((T) (expr)); \ + JSON_HEDLEY_DIAGNOSTIC_POP \ + })) +#else +# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(JSON_HEDLEY_REINTERPRET_CAST) + #undef JSON_HEDLEY_REINTERPRET_CAST +#endif +#if defined(__cplusplus) + #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) +#else + #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(JSON_HEDLEY_STATIC_CAST) + #undef JSON_HEDLEY_STATIC_CAST +#endif +#if defined(__cplusplus) + #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) +#else + #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(JSON_HEDLEY_CPP_CAST) + #undef JSON_HEDLEY_CPP_CAST +#endif +#if defined(__cplusplus) +# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast") +# define JSON_HEDLEY_CPP_CAST(T, expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \ + ((T) (expr)) \ + JSON_HEDLEY_DIAGNOSTIC_POP +# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0) +# define JSON_HEDLEY_CPP_CAST(T, expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("diag_suppress=Pe137") \ + JSON_HEDLEY_DIAGNOSTIC_POP +# else +# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr)) +# endif +#else +# define JSON_HEDLEY_CPP_CAST(T, expr) (expr) +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") +#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786)) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445") +#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) +#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") +#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161)) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") +#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") +#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)") +#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292)) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098") +#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") +#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunused-function") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505)) +#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION +#endif + +#if defined(JSON_HEDLEY_DEPRECATED) + #undef JSON_HEDLEY_DEPRECATED +#endif +#if defined(JSON_HEDLEY_DEPRECATED_FOR) + #undef JSON_HEDLEY_DEPRECATED_FOR +#endif +#if \ + JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) +#elif \ + (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) +#elif defined(__cplusplus) && (__cplusplus >= 201402L) + #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) +#elif \ + JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) + #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") +#else + #define JSON_HEDLEY_DEPRECATED(since) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) +#endif + +#if defined(JSON_HEDLEY_UNAVAILABLE) + #undef JSON_HEDLEY_UNAVAILABLE +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) +#else + #define JSON_HEDLEY_UNAVAILABLE(available_since) +#endif + +#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) + #undef JSON_HEDLEY_WARN_UNUSED_RESULT +#endif +#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) + #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) +#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) + #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) +#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) + #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) +#elif defined(_Check_return_) /* SAL */ + #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_ +#else + #define JSON_HEDLEY_WARN_UNUSED_RESULT + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) +#endif + +#if defined(JSON_HEDLEY_SENTINEL) + #undef JSON_HEDLEY_SENTINEL +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) +#else + #define JSON_HEDLEY_SENTINEL(position) +#endif + +#if defined(JSON_HEDLEY_NO_RETURN) + #undef JSON_HEDLEY_NO_RETURN +#endif +#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_NO_RETURN __noreturn +#elif \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + #define JSON_HEDLEY_NO_RETURN _Noreturn +#elif defined(__cplusplus) && (__cplusplus >= 201103L) + #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]]) +#elif \ + JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) + #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) + #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) +#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") +#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) +#else + #define JSON_HEDLEY_NO_RETURN +#endif + +#if defined(JSON_HEDLEY_NO_ESCAPE) + #undef JSON_HEDLEY_NO_ESCAPE +#endif +#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape) + #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__)) +#else + #define JSON_HEDLEY_NO_ESCAPE +#endif + +#if defined(JSON_HEDLEY_UNREACHABLE) + #undef JSON_HEDLEY_UNREACHABLE +#endif +#if defined(JSON_HEDLEY_UNREACHABLE_RETURN) + #undef JSON_HEDLEY_UNREACHABLE_RETURN +#endif +#if defined(JSON_HEDLEY_ASSUME) + #undef JSON_HEDLEY_ASSUME +#endif +#if \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_ASSUME(expr) __assume(expr) +#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) + #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) +#elif \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) + #if defined(__cplusplus) + #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) + #else + #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) + #endif +#endif +#if \ + (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() +#elif defined(JSON_HEDLEY_ASSUME) + #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) +#endif +#if !defined(JSON_HEDLEY_ASSUME) + #if defined(JSON_HEDLEY_UNREACHABLE) + #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1))) + #else + #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr) + #endif +#endif +#if defined(JSON_HEDLEY_UNREACHABLE) + #if \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value)) + #else + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() + #endif +#else + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value) +#endif +#if !defined(JSON_HEDLEY_UNREACHABLE) + #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) +#endif + +JSON_HEDLEY_DIAGNOSTIC_PUSH +#if JSON_HEDLEY_HAS_WARNING("-Wpedantic") + #pragma clang diagnostic ignored "-Wpedantic" +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus) + #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif +#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wvariadic-macros" + #elif defined(JSON_HEDLEY_GCC_VERSION) + #pragma GCC diagnostic ignored "-Wvariadic-macros" + #endif +#endif +#if defined(JSON_HEDLEY_NON_NULL) + #undef JSON_HEDLEY_NON_NULL +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) +#else + #define JSON_HEDLEY_NON_NULL(...) +#endif +JSON_HEDLEY_DIAGNOSTIC_POP + +#if defined(JSON_HEDLEY_PRINTF_FORMAT) + #undef JSON_HEDLEY_PRINTF_FORMAT +#endif +#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) +#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) +#elif \ + JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) +#else + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) +#endif + +#if defined(JSON_HEDLEY_CONSTEXPR) + #undef JSON_HEDLEY_CONSTEXPR +#endif +#if defined(__cplusplus) + #if __cplusplus >= 201103L + #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr) + #endif +#endif +#if !defined(JSON_HEDLEY_CONSTEXPR) + #define JSON_HEDLEY_CONSTEXPR +#endif + +#if defined(JSON_HEDLEY_PREDICT) + #undef JSON_HEDLEY_PREDICT +#endif +#if defined(JSON_HEDLEY_LIKELY) + #undef JSON_HEDLEY_LIKELY +#endif +#if defined(JSON_HEDLEY_UNLIKELY) + #undef JSON_HEDLEY_UNLIKELY +#endif +#if defined(JSON_HEDLEY_UNPREDICTABLE) + #undef JSON_HEDLEY_UNPREDICTABLE +#endif +#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) + #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) +#endif +#if \ + (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) +# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability)) +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability)) +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability)) +# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 ) +# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 ) +#elif \ + (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) +# define JSON_HEDLEY_PREDICT(expr, expected, probability) \ + (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ + (__extension__ ({ \ + double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ + })) +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ + (__extension__ ({ \ + double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ + })) +# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +#else +# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)) +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) +# define JSON_HEDLEY_LIKELY(expr) (!!(expr)) +# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) +#endif +#if !defined(JSON_HEDLEY_UNPREDICTABLE) + #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5) +#endif + +#if defined(JSON_HEDLEY_MALLOC) + #undef JSON_HEDLEY_MALLOC +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) + #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_MALLOC __declspec(restrict) +#else + #define JSON_HEDLEY_MALLOC +#endif + +#if defined(JSON_HEDLEY_PURE) + #undef JSON_HEDLEY_PURE +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) +# define JSON_HEDLEY_PURE __attribute__((__pure__)) +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) +# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") +#elif defined(__cplusplus) && \ + ( \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \ + ) +# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") +#else +# define JSON_HEDLEY_PURE +#endif + +#if defined(JSON_HEDLEY_CONST) + #undef JSON_HEDLEY_CONST +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_CONST __attribute__((__const__)) +#elif \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) + #define JSON_HEDLEY_CONST _Pragma("no_side_effect") +#else + #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE +#endif + +#if defined(JSON_HEDLEY_RESTRICT) + #undef JSON_HEDLEY_RESTRICT +#endif +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) + #define JSON_HEDLEY_RESTRICT restrict +#elif \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + defined(__clang__) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_RESTRICT __restrict +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) + #define JSON_HEDLEY_RESTRICT _Restrict +#else + #define JSON_HEDLEY_RESTRICT +#endif + +#if defined(JSON_HEDLEY_INLINE) + #undef JSON_HEDLEY_INLINE +#endif +#if \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ + (defined(__cplusplus) && (__cplusplus >= 199711L)) + #define JSON_HEDLEY_INLINE inline +#elif \ + defined(JSON_HEDLEY_GCC_VERSION) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) + #define JSON_HEDLEY_INLINE __inline__ +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_INLINE __inline +#else + #define JSON_HEDLEY_INLINE +#endif + +#if defined(JSON_HEDLEY_ALWAYS_INLINE) + #undef JSON_HEDLEY_ALWAYS_INLINE +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) +# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) +# define JSON_HEDLEY_ALWAYS_INLINE __forceinline +#elif defined(__cplusplus) && \ + ( \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \ + ) +# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") +#else +# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE +#endif + +#if defined(JSON_HEDLEY_NEVER_INLINE) + #undef JSON_HEDLEY_NEVER_INLINE +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ + (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) + #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") +#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") +#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) +#else + #define JSON_HEDLEY_NEVER_INLINE +#endif + +#if defined(JSON_HEDLEY_PRIVATE) + #undef JSON_HEDLEY_PRIVATE +#endif +#if defined(JSON_HEDLEY_PUBLIC) + #undef JSON_HEDLEY_PUBLIC +#endif +#if defined(JSON_HEDLEY_IMPORT) + #undef JSON_HEDLEY_IMPORT +#endif +#if defined(_WIN32) || defined(__CYGWIN__) +# define JSON_HEDLEY_PRIVATE +# define JSON_HEDLEY_PUBLIC __declspec(dllexport) +# define JSON_HEDLEY_IMPORT __declspec(dllimport) +#else +# if \ + JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + ( \ + defined(__TI_EABI__) && \ + ( \ + (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \ + ) \ + ) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) +# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) +# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) +# else +# define JSON_HEDLEY_PRIVATE +# define JSON_HEDLEY_PUBLIC +# endif +# define JSON_HEDLEY_IMPORT extern +#endif + +#if defined(JSON_HEDLEY_NO_THROW) + #undef JSON_HEDLEY_NO_THROW +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define JSON_HEDLEY_NO_THROW __declspec(nothrow) +#else + #define JSON_HEDLEY_NO_THROW +#endif + +#if defined(JSON_HEDLEY_FALL_THROUGH) + #undef JSON_HEDLEY_FALL_THROUGH +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) +#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) + #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) +#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough) + #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]]) +#elif defined(__fallthrough) /* SAL */ + #define JSON_HEDLEY_FALL_THROUGH __fallthrough +#else + #define JSON_HEDLEY_FALL_THROUGH +#endif + +#if defined(JSON_HEDLEY_RETURNS_NON_NULL) + #undef JSON_HEDLEY_RETURNS_NON_NULL +#endif +#if \ + JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) +#elif defined(_Ret_notnull_) /* SAL */ + #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ +#else + #define JSON_HEDLEY_RETURNS_NON_NULL +#endif + +#if defined(JSON_HEDLEY_ARRAY_PARAM) + #undef JSON_HEDLEY_ARRAY_PARAM +#endif +#if \ + defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ + !defined(__STDC_NO_VLA__) && \ + !defined(__cplusplus) && \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_TINYC_VERSION) + #define JSON_HEDLEY_ARRAY_PARAM(name) (name) +#else + #define JSON_HEDLEY_ARRAY_PARAM(name) +#endif + +#if defined(JSON_HEDLEY_IS_CONSTANT) + #undef JSON_HEDLEY_IS_CONSTANT +#endif +#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR) + #undef JSON_HEDLEY_REQUIRE_CONSTEXPR +#endif +/* JSON_HEDLEY_IS_CONSTEXPR_ is for + HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ +#if defined(JSON_HEDLEY_IS_CONSTEXPR_) + #undef JSON_HEDLEY_IS_CONSTEXPR_ +#endif +#if \ + JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) +#endif +#if !defined(__cplusplus) +# if \ + JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) +#if defined(__INTPTR_TYPE__) + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) +#else + #include + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) +#endif +# elif \ + ( \ + defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ + !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_IAR_VERSION)) || \ + (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) +#if defined(__INTPTR_TYPE__) + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) +#else + #include + #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) +#endif +# elif \ + defined(JSON_HEDLEY_GCC_VERSION) || \ + defined(JSON_HEDLEY_INTEL_VERSION) || \ + defined(JSON_HEDLEY_TINYC_VERSION) || \ + defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \ + defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ + defined(JSON_HEDLEY_TI_CL6X_VERSION) || \ + defined(JSON_HEDLEY_TI_CL7X_VERSION) || \ + defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \ + defined(__clang__) +# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ + sizeof(void) != \ + sizeof(*( \ + 1 ? \ + ((void*) ((expr) * 0L) ) : \ +((struct { char v[sizeof(void) * 2]; } *) 1) \ + ) \ + ) \ + ) +# endif +#endif +#if defined(JSON_HEDLEY_IS_CONSTEXPR_) + #if !defined(JSON_HEDLEY_IS_CONSTANT) + #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr) + #endif + #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1)) +#else + #if !defined(JSON_HEDLEY_IS_CONSTANT) + #define JSON_HEDLEY_IS_CONSTANT(expr) (0) + #endif + #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) +#endif + +#if defined(JSON_HEDLEY_BEGIN_C_DECLS) + #undef JSON_HEDLEY_BEGIN_C_DECLS +#endif +#if defined(JSON_HEDLEY_END_C_DECLS) + #undef JSON_HEDLEY_END_C_DECLS +#endif +#if defined(JSON_HEDLEY_C_DECL) + #undef JSON_HEDLEY_C_DECL +#endif +#if defined(__cplusplus) + #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" { + #define JSON_HEDLEY_END_C_DECLS } + #define JSON_HEDLEY_C_DECL extern "C" +#else + #define JSON_HEDLEY_BEGIN_C_DECLS + #define JSON_HEDLEY_END_C_DECLS + #define JSON_HEDLEY_C_DECL +#endif + +#if defined(JSON_HEDLEY_STATIC_ASSERT) + #undef JSON_HEDLEY_STATIC_ASSERT +#endif +#if \ + !defined(__cplusplus) && ( \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ + (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + defined(_Static_assert) \ + ) +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) +#elif \ + (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ + JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) +#else +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) +#endif + +#if defined(JSON_HEDLEY_NULL) + #undef JSON_HEDLEY_NULL +#endif +#if defined(__cplusplus) + #if __cplusplus >= 201103L + #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr) + #elif defined(NULL) + #define JSON_HEDLEY_NULL NULL + #else + #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0) + #endif +#elif defined(NULL) + #define JSON_HEDLEY_NULL NULL +#else + #define JSON_HEDLEY_NULL ((void*) 0) +#endif + +#if defined(JSON_HEDLEY_MESSAGE) + #undef JSON_HEDLEY_MESSAGE +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define JSON_HEDLEY_MESSAGE(msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + JSON_HEDLEY_PRAGMA(message msg) \ + JSON_HEDLEY_DIAGNOSTIC_POP +#elif \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) +#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) +#else +# define JSON_HEDLEY_MESSAGE(msg) +#endif + +#if defined(JSON_HEDLEY_WARNING) + #undef JSON_HEDLEY_WARNING +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define JSON_HEDLEY_WARNING(msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + JSON_HEDLEY_PRAGMA(clang warning msg) \ + JSON_HEDLEY_DIAGNOSTIC_POP +#elif \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) +#else +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) +#endif + +#if defined(JSON_HEDLEY_REQUIRE) + #undef JSON_HEDLEY_REQUIRE +#endif +#if defined(JSON_HEDLEY_REQUIRE_MSG) + #undef JSON_HEDLEY_REQUIRE_MSG +#endif +#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) +# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") +# define JSON_HEDLEY_REQUIRE(expr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ + __attribute__((diagnose_if(!(expr), #expr, "error"))) \ + JSON_HEDLEY_DIAGNOSTIC_POP +# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ + __attribute__((diagnose_if(!(expr), msg, "error"))) \ + JSON_HEDLEY_DIAGNOSTIC_POP +# else +# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error"))) +# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error"))) +# endif +#else +# define JSON_HEDLEY_REQUIRE(expr) +# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) +#endif + +#if defined(JSON_HEDLEY_FLAGS) + #undef JSON_HEDLEY_FLAGS +#endif +#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion")) + #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) +#else + #define JSON_HEDLEY_FLAGS +#endif + +#if defined(JSON_HEDLEY_FLAGS_CAST) + #undef JSON_HEDLEY_FLAGS_CAST +#endif +#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) +# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("warning(disable:188)") \ + ((T) (expr)); \ + JSON_HEDLEY_DIAGNOSTIC_POP \ + })) +#else +# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) +#endif + +#if defined(JSON_HEDLEY_EMPTY_BASES) + #undef JSON_HEDLEY_EMPTY_BASES +#endif +#if \ + (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) +#else + #define JSON_HEDLEY_EMPTY_BASES +#endif + +/* Remaining macros are deprecated. */ + +#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) + #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK +#endif +#if defined(__clang__) + #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) +#else + #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE +#endif +#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) + +#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE +#endif +#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) + +#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN) + #undef JSON_HEDLEY_CLANG_HAS_BUILTIN +#endif +#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin) + +#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE) + #undef JSON_HEDLEY_CLANG_HAS_FEATURE +#endif +#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature) + +#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION) + #undef JSON_HEDLEY_CLANG_HAS_EXTENSION +#endif +#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension) + +#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE +#endif +#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) + +#if defined(JSON_HEDLEY_CLANG_HAS_WARNING) + #undef JSON_HEDLEY_CLANG_HAS_WARNING +#endif +#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning) + +#endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */ + + +// This file contains all internal macro definitions (except those affecting ABI) +// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them + +// #include + + +// exclude unsupported compilers +#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) + #if defined(__clang__) + #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 + #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" + #endif + #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) + #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 + #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" + #endif + #endif +#endif + +// C++ language standard detection +// if the user manually specified the used c++ version this is skipped +#if !defined(JSON_HAS_CPP_23) && !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11) + #if (defined(__cplusplus) && __cplusplus > 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202002L) + #define JSON_HAS_CPP_23 + #define JSON_HAS_CPP_20 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 + #elif (defined(__cplusplus) && __cplusplus > 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG > 201703L) + #define JSON_HAS_CPP_20 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 + #elif (defined(__cplusplus) && __cplusplus > 201402L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 + #elif (defined(__cplusplus) && __cplusplus > 201103L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) + #define JSON_HAS_CPP_14 + #endif + // the cpp 11 flag is always specified because it is the minimal required version + #define JSON_HAS_CPP_11 +#endif + +#ifdef __has_include + #if __has_include() + #include + #endif +#endif + +#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) + #ifdef JSON_HAS_CPP_17 + #if defined(__cpp_lib_filesystem) + #define JSON_HAS_FILESYSTEM 1 + #elif defined(__cpp_lib_experimental_filesystem) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif !defined(__has_include) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #endif + + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before GCC 8: https://en.cppreference.com/w/cpp/compiler_support + #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before Clang 7: https://en.cppreference.com/w/cpp/compiler_support + #if defined(__clang_major__) && __clang_major__ < 7 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before MSVC 19.14: https://en.cppreference.com/w/cpp/compiler_support + #if defined(_MSC_VER) && _MSC_VER < 1914 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before iOS 13 + #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before macOS Catalina + #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + #endif +#endif + +#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0 +#endif + +#ifndef JSON_HAS_FILESYSTEM + #define JSON_HAS_FILESYSTEM 0 +#endif + +#ifndef JSON_HAS_THREE_WAY_COMPARISON + #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \ + && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L + #define JSON_HAS_THREE_WAY_COMPARISON 1 + #else + #define JSON_HAS_THREE_WAY_COMPARISON 0 + #endif +#endif + +#ifndef JSON_HAS_RANGES + // ranges header shipping in GCC 11.1.0 (released 2021-04-27) has syntax error + #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427 + #define JSON_HAS_RANGES 0 + #elif defined(__cpp_lib_ranges) + #define JSON_HAS_RANGES 1 + #else + #define JSON_HAS_RANGES 0 + #endif +#endif + +#ifndef JSON_HAS_STATIC_RTTI + #if !defined(_HAS_STATIC_RTTI) || _HAS_STATIC_RTTI != 0 + #define JSON_HAS_STATIC_RTTI 1 + #else + #define JSON_HAS_STATIC_RTTI 0 + #endif +#endif + +#ifdef JSON_HAS_CPP_17 + #define JSON_INLINE_VARIABLE inline +#else + #define JSON_INLINE_VARIABLE +#endif + +#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address) + #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]] +#else + #define JSON_NO_UNIQUE_ADDRESS +#endif + +// disable documentation warnings on clang +#if defined(__clang__) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdocumentation" + #pragma clang diagnostic ignored "-Wdocumentation-unknown-command" +#endif + +// allow disabling exceptions +#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) + #define JSON_THROW(exception) throw exception + #define JSON_TRY try + #define JSON_CATCH(exception) catch(exception) + #define JSON_INTERNAL_CATCH(exception) catch(exception) +#else + #include + #define JSON_THROW(exception) std::abort() + #define JSON_TRY if(true) + #define JSON_CATCH(exception) if(false) + #define JSON_INTERNAL_CATCH(exception) if(false) +#endif + +// override exception macros +#if defined(JSON_THROW_USER) + #undef JSON_THROW + #define JSON_THROW JSON_THROW_USER +#endif +#if defined(JSON_TRY_USER) + #undef JSON_TRY + #define JSON_TRY JSON_TRY_USER +#endif +#if defined(JSON_CATCH_USER) + #undef JSON_CATCH + #define JSON_CATCH JSON_CATCH_USER + #undef JSON_INTERNAL_CATCH + #define JSON_INTERNAL_CATCH JSON_CATCH_USER +#endif +#if defined(JSON_INTERNAL_CATCH_USER) + #undef JSON_INTERNAL_CATCH + #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER +#endif + +// allow overriding assert +#if !defined(JSON_ASSERT) + #include // assert + #define JSON_ASSERT(x) assert(x) +#endif + +// allow to access some private functions (needed by the test suite) +#if defined(JSON_TESTS_PRIVATE) + #define JSON_PRIVATE_UNLESS_TESTED public +#else + #define JSON_PRIVATE_UNLESS_TESTED private +#endif + +/*! +@brief macro to briefly define a mapping between an enum and JSON +@def NLOHMANN_JSON_SERIALIZE_ENUM +@since version 3.4.0 +*/ +#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ + template \ + inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ + { \ + /* NOLINTNEXTLINE(modernize-type-traits) we use C++11 */ \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + /* NOLINTNEXTLINE(modernize-avoid-c-arrays) we don't want to depend on */ \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), \ + [e](const std::pair& ej_pair) -> bool \ + { \ + return ej_pair.first == e; \ + }); \ + j = ((it != std::end(m)) ? it : std::begin(m))->second; \ + } \ + template \ + inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ + { \ + /* NOLINTNEXTLINE(modernize-type-traits) we use C++11 */ \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + /* NOLINTNEXTLINE(modernize-avoid-c-arrays) we don't want to depend on */ \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), \ + [&j](const std::pair& ej_pair) -> bool \ + { \ + return ej_pair.second == j; \ + }); \ + e = ((it != std::end(m)) ? it : std::begin(m))->first; \ + } + +// Ugly macros to avoid uglier copy-paste when specializing basic_json. They +// may be removed in the future once the class is split. + +#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ + template class ObjectType, \ + template class ArrayType, \ + class StringType, class BooleanType, class NumberIntegerType, \ + class NumberUnsignedType, class NumberFloatType, \ + template class AllocatorType, \ + template class JSONSerializer, \ + class BinaryType, \ + class CustomBaseClass> + +#define NLOHMANN_BASIC_JSON_TPL \ + basic_json + +// Macros to simplify conversion from/to types + +#define NLOHMANN_JSON_EXPAND( x ) x +#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME +#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ + NLOHMANN_JSON_PASTE64, \ + NLOHMANN_JSON_PASTE63, \ + NLOHMANN_JSON_PASTE62, \ + NLOHMANN_JSON_PASTE61, \ + NLOHMANN_JSON_PASTE60, \ + NLOHMANN_JSON_PASTE59, \ + NLOHMANN_JSON_PASTE58, \ + NLOHMANN_JSON_PASTE57, \ + NLOHMANN_JSON_PASTE56, \ + NLOHMANN_JSON_PASTE55, \ + NLOHMANN_JSON_PASTE54, \ + NLOHMANN_JSON_PASTE53, \ + NLOHMANN_JSON_PASTE52, \ + NLOHMANN_JSON_PASTE51, \ + NLOHMANN_JSON_PASTE50, \ + NLOHMANN_JSON_PASTE49, \ + NLOHMANN_JSON_PASTE48, \ + NLOHMANN_JSON_PASTE47, \ + NLOHMANN_JSON_PASTE46, \ + NLOHMANN_JSON_PASTE45, \ + NLOHMANN_JSON_PASTE44, \ + NLOHMANN_JSON_PASTE43, \ + NLOHMANN_JSON_PASTE42, \ + NLOHMANN_JSON_PASTE41, \ + NLOHMANN_JSON_PASTE40, \ + NLOHMANN_JSON_PASTE39, \ + NLOHMANN_JSON_PASTE38, \ + NLOHMANN_JSON_PASTE37, \ + NLOHMANN_JSON_PASTE36, \ + NLOHMANN_JSON_PASTE35, \ + NLOHMANN_JSON_PASTE34, \ + NLOHMANN_JSON_PASTE33, \ + NLOHMANN_JSON_PASTE32, \ + NLOHMANN_JSON_PASTE31, \ + NLOHMANN_JSON_PASTE30, \ + NLOHMANN_JSON_PASTE29, \ + NLOHMANN_JSON_PASTE28, \ + NLOHMANN_JSON_PASTE27, \ + NLOHMANN_JSON_PASTE26, \ + NLOHMANN_JSON_PASTE25, \ + NLOHMANN_JSON_PASTE24, \ + NLOHMANN_JSON_PASTE23, \ + NLOHMANN_JSON_PASTE22, \ + NLOHMANN_JSON_PASTE21, \ + NLOHMANN_JSON_PASTE20, \ + NLOHMANN_JSON_PASTE19, \ + NLOHMANN_JSON_PASTE18, \ + NLOHMANN_JSON_PASTE17, \ + NLOHMANN_JSON_PASTE16, \ + NLOHMANN_JSON_PASTE15, \ + NLOHMANN_JSON_PASTE14, \ + NLOHMANN_JSON_PASTE13, \ + NLOHMANN_JSON_PASTE12, \ + NLOHMANN_JSON_PASTE11, \ + NLOHMANN_JSON_PASTE10, \ + NLOHMANN_JSON_PASTE9, \ + NLOHMANN_JSON_PASTE8, \ + NLOHMANN_JSON_PASTE7, \ + NLOHMANN_JSON_PASTE6, \ + NLOHMANN_JSON_PASTE5, \ + NLOHMANN_JSON_PASTE4, \ + NLOHMANN_JSON_PASTE3, \ + NLOHMANN_JSON_PASTE2, \ + NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) +#define NLOHMANN_JSON_PASTE2(func, v1) func(v1) +#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) +#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) +#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4) +#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5) +#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6) +#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7) +#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8) +#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) +#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) +#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) +#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) +#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) +#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) +#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) +#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) +#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) +#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) +#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) +#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) +#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) +#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) +#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) +#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) +#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) +#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) +#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) +#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) +#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) +#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) +#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) +#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) +#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) +#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) +#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) +#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) +#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) +#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) +#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) +#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) +#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) +#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) +#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) +#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) +#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) +#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) +#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) +#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) +#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) +#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) +#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) +#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) +#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) +#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) +#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) +#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) +#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) +#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) +#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) +#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) +#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) +#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) +#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) + +#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; +#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); +#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = !nlohmann_json_j.is_null() ? nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1) : nlohmann_json_default_obj.v1; + +/*! +@brief macro +@def NLOHMANN_DEFINE_TYPE_INTRUSIVE +@since version 3.9.0 +@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/ +*/ +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ + template::value, int> = 0> \ + friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + template::value, int> = 0> \ + friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } + +/*! +@brief macro +@def NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT +@since version 3.11.0 +@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/ +*/ +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \ + template::value, int> = 0> \ + friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + template::value, int> = 0> \ + friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } + +/*! +@brief macro +@def NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE +@since version 3.11.3 +@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/ +*/ +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ + template::value, int> = 0> \ + friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } + +/*! +@brief macro +@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE +@since version 3.9.0 +@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/ +*/ +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ + template::value, int> = 0> \ + void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + template::value, int> = 0> \ + void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } + +/*! +@brief macro +@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT +@since version 3.11.0 +@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/ +*/ +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \ + template::value, int> = 0> \ + void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + template::value, int> = 0> \ + void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } + +/*! +@brief macro +@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE +@since version 3.11.3 +@sa https://json.nlohmann.me/api/macros/nlohmann_define_type_non_intrusive/ +*/ +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, ...) \ + template::value, int> = 0> \ + void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } + +/*! +@brief macro +@def NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE +@since version 3.12.0 +@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/ +*/ +#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE(Type, BaseType, ...) \ + template::value, int> = 0> \ + friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + template::value, int> = 0> \ + friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } + +/*! +@brief macro +@def NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT +@since version 3.12.0 +@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/ +*/ +#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \ + template::value, int> = 0> \ + friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + template::value, int> = 0> \ + friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } + +/*! +@brief macro +@def NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE +@since version 3.12.0 +@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/ +*/ +#define NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \ + template::value, int> = 0> \ + friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } + +/*! +@brief macro +@def NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE +@since version 3.12.0 +@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/ +*/ +#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE(Type, BaseType, ...) \ + template::value, int> = 0> \ + void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + template::value, int> = 0> \ + void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } + +/*! +@brief macro +@def NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT +@since version 3.12.0 +@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/ +*/ +#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, BaseType, ...) \ + template::value, int> = 0> \ + void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + template::value, int> = 0> \ + void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { nlohmann::from_json(nlohmann_json_j, static_cast(nlohmann_json_t)); const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } + +/*! +@brief macro +@def NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE +@since version 3.12.0 +@sa https://json.nlohmann.me/api/macros/nlohmann_define_derived_type/ +*/ +#define NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE(Type, BaseType, ...) \ + template::value, int> = 0> \ + void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { nlohmann::to_json(nlohmann_json_j, static_cast(nlohmann_json_t)); NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } + +// inspired from https://stackoverflow.com/a/26745591 +// allows calling any std function as if (e.g., with begin): +// using std::begin; begin(x); +// +// it allows using the detected idiom to retrieve the return type +// of such an expression +#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ + namespace detail { \ + using std::std_name; \ + \ + template \ + using result_of_##std_name = decltype(std_name(std::declval()...)); \ + } \ + \ + namespace detail2 { \ + struct std_name##_tag \ + { \ + }; \ + \ + template \ + std_name##_tag std_name(T&&...); \ + \ + template \ + using result_of_##std_name = decltype(std_name(std::declval()...)); \ + \ + template \ + struct would_call_std_##std_name \ + { \ + static constexpr auto const value = ::nlohmann::detail:: \ + is_detected_exact::value; \ + }; \ + } /* namespace detail2 */ \ + \ + template \ + struct would_call_std_##std_name : detail2::would_call_std_##std_name \ + { \ + } + +#ifndef JSON_USE_IMPLICIT_CONVERSIONS + #define JSON_USE_IMPLICIT_CONVERSIONS 1 +#endif + +#if JSON_USE_IMPLICIT_CONVERSIONS + #define JSON_EXPLICIT +#else + #define JSON_EXPLICIT explicit +#endif + +#ifndef JSON_DISABLE_ENUM_SERIALIZATION + #define JSON_DISABLE_ENUM_SERIALIZATION 0 +#endif + +#ifndef JSON_USE_GLOBAL_UDLS + #define JSON_USE_GLOBAL_UDLS 1 +#endif + +#if JSON_HAS_THREE_WAY_COMPARISON + #include // partial_ordering +#endif + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +/////////////////////////// +// JSON type enumeration // +/////////////////////////// + +/*! +@brief the JSON type enumeration + +This enumeration collects the different JSON types. It is internally used to +distinguish the stored values, and the functions @ref basic_json::is_null(), +@ref basic_json::is_object(), @ref basic_json::is_array(), +@ref basic_json::is_string(), @ref basic_json::is_boolean(), +@ref basic_json::is_number() (with @ref basic_json::is_number_integer(), +@ref basic_json::is_number_unsigned(), and @ref basic_json::is_number_float()), +@ref basic_json::is_discarded(), @ref basic_json::is_primitive(), and +@ref basic_json::is_structured() rely on it. + +@note There are three enumeration entries (number_integer, number_unsigned, and +number_float), because the library distinguishes these three types for numbers: +@ref basic_json::number_unsigned_t is used for unsigned integers, +@ref basic_json::number_integer_t is used for signed integers, and +@ref basic_json::number_float_t is used for floating-point numbers or to +approximate integers which do not fit in the limits of their respective type. + +@sa see @ref basic_json::basic_json(const value_t value_type) -- create a JSON +value with the default value for a given type + +@since version 1.0.0 +*/ +enum class value_t : std::uint8_t +{ + null, ///< null value + object, ///< object (unordered set of name/value pairs) + array, ///< array (ordered collection of values) + string, ///< string value + boolean, ///< boolean value + number_integer, ///< number value (signed integer) + number_unsigned, ///< number value (unsigned integer) + number_float, ///< number value (floating-point) + binary, ///< binary array (ordered collection of bytes) + discarded ///< discarded by the parser callback function +}; + +/*! +@brief comparison operator for JSON types + +Returns an ordering that is similar to Python: +- order: null < boolean < number < object < array < string < binary +- furthermore, each type is not smaller than itself +- discarded values are not comparable +- binary is represented as a b"" string in python and directly comparable to a + string; however, making a binary array directly comparable with a string would + be surprising behavior in a JSON file. + +@since version 1.0.0 +*/ +#if JSON_HAS_THREE_WAY_COMPARISON + inline std::partial_ordering operator<=>(const value_t lhs, const value_t rhs) noexcept // *NOPAD* +#else + inline bool operator<(const value_t lhs, const value_t rhs) noexcept +#endif +{ + static constexpr std::array order = {{ + 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, + 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */, + 6 /* binary */ + } + }; + + const auto l_index = static_cast(lhs); + const auto r_index = static_cast(rhs); +#if JSON_HAS_THREE_WAY_COMPARISON + if (l_index < order.size() && r_index < order.size()) + { + return order[l_index] <=> order[r_index]; // *NOPAD* + } + return std::partial_ordering::unordered; +#else + return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index]; +#endif +} + +// GCC selects the built-in operator< over an operator rewritten from +// a user-defined spaceship operator +// Clang, MSVC, and ICC select the rewritten candidate +// (see GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105200) +#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__) +inline bool operator<(const value_t lhs, const value_t rhs) noexcept +{ + return std::is_lt(lhs <=> rhs); // *NOPAD* +} +#endif + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +/*! +@brief replace all occurrences of a substring by another string + +@param[in,out] s the string to manipulate; changed so that all + occurrences of @a f are replaced with @a t +@param[in] f the substring to replace with @a t +@param[in] t the string to replace @a f + +@pre The search string @a f must not be empty. **This precondition is +enforced with an assertion.** + +@since version 2.0.0 +*/ +template +inline void replace_substring(StringType& s, const StringType& f, + const StringType& t) +{ + JSON_ASSERT(!f.empty()); + for (auto pos = s.find(f); // find first occurrence of f + pos != StringType::npos; // make sure f was found + s.replace(pos, f.size(), t), // replace with t, and + pos = s.find(f, pos + t.size())) // find next occurrence of f + {} +} + +/*! + * @brief string escaping as described in RFC 6901 (Sect. 4) + * @param[in] s string to escape + * @return escaped string + * + * Note the order of escaping "~" to "~0" and "/" to "~1" is important. + */ +template +inline StringType escape(StringType s) +{ + replace_substring(s, StringType{"~"}, StringType{"~0"}); + replace_substring(s, StringType{"/"}, StringType{"~1"}); + return s; +} + +/*! + * @brief string unescaping as described in RFC 6901 (Sect. 4) + * @param[in] s string to unescape + * @return unescaped string + * + * Note the order of escaping "~1" to "/" and "~0" to "~" is important. + */ +template +static void unescape(StringType& s) +{ + replace_substring(s, StringType{"~1"}, StringType{"/"}); + replace_substring(s, StringType{"~0"}, StringType{"~"}); +} + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include // size_t + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +/// struct to capture the start position of the current token +struct position_t +{ + /// the total number of characters read + std::size_t chars_read_total = 0; + /// the number of characters read in the current line + std::size_t chars_read_current_line = 0; + /// the number of lines read + std::size_t lines_read = 0; + + /// conversion to size_t to preserve SAX interface + constexpr operator size_t() const + { + return chars_read_total; + } +}; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + +// #include + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-FileCopyrightText: 2018 The Abseil Authors +// SPDX-License-Identifier: MIT + + + +#include // array +#include // size_t +#include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type +#include // index_sequence, make_index_sequence, index_sequence_for + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +template +using uncvref_t = typename std::remove_cv::type>::type; + +#ifdef JSON_HAS_CPP_14 + +// the following utilities are natively available in C++14 +using std::enable_if_t; +using std::index_sequence; +using std::make_index_sequence; +using std::index_sequence_for; + +#else + +// alias templates to reduce boilerplate +template +using enable_if_t = typename std::enable_if::type; + +// The following code is taken from https://github.com/abseil/abseil-cpp/blob/10cb35e459f5ecca5b2ff107635da0bfa41011b4/absl/utility/utility.h +// which is part of Google Abseil (https://github.com/abseil/abseil-cpp), licensed under the Apache License 2.0. + +//// START OF CODE FROM GOOGLE ABSEIL + +// integer_sequence +// +// Class template representing a compile-time integer sequence. An instantiation +// of `integer_sequence` has a sequence of integers encoded in its +// type through its template arguments (which is a common need when +// working with C++11 variadic templates). `absl::integer_sequence` is designed +// to be a drop-in replacement for C++14's `std::integer_sequence`. +// +// Example: +// +// template< class T, T... Ints > +// void user_function(integer_sequence); +// +// int main() +// { +// // user_function's `T` will be deduced to `int` and `Ints...` +// // will be deduced to `0, 1, 2, 3, 4`. +// user_function(make_integer_sequence()); +// } +template +struct integer_sequence +{ + using value_type = T; + static constexpr std::size_t size() noexcept + { + return sizeof...(Ints); + } +}; + +// index_sequence +// +// A helper template for an `integer_sequence` of `size_t`, +// `absl::index_sequence` is designed to be a drop-in replacement for C++14's +// `std::index_sequence`. +template +using index_sequence = integer_sequence; + +namespace utility_internal +{ + +template +struct Extend; + +// Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency. +template +struct Extend, SeqSize, 0> +{ + using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >; +}; + +template +struct Extend, SeqSize, 1> +{ + using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >; +}; + +// Recursion helper for 'make_integer_sequence'. +// 'Gen::type' is an alias for 'integer_sequence'. +template +struct Gen +{ + using type = + typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type; +}; + +template +struct Gen +{ + using type = integer_sequence; +}; + +} // namespace utility_internal + +// Compile-time sequences of integers + +// make_integer_sequence +// +// This template alias is equivalent to +// `integer_sequence`, and is designed to be a drop-in +// replacement for C++14's `std::make_integer_sequence`. +template +using make_integer_sequence = typename utility_internal::Gen::type; + +// make_index_sequence +// +// This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`, +// and is designed to be a drop-in replacement for C++14's +// `std::make_index_sequence`. +template +using make_index_sequence = make_integer_sequence; + +// index_sequence_for +// +// Converts a typename pack into an index sequence of the same length, and +// is designed to be a drop-in replacement for C++14's +// `std::index_sequence_for()` +template +using index_sequence_for = make_index_sequence; + +//// END OF CODE FROM GOOGLE ABSEIL + +#endif + +// dispatch utility (taken from ranges-v3) +template struct priority_tag : priority_tag < N - 1 > {}; +template<> struct priority_tag<0> {}; + +// taken from ranges-v3 +template +struct static_const +{ + static JSON_INLINE_VARIABLE constexpr T value{}; +}; + +#ifndef JSON_HAS_CPP_17 + template + constexpr T static_const::value; +#endif + +template +constexpr std::array make_array(Args&& ... args) +{ + return std::array {{static_cast(std::forward(args))...}}; +} + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include // numeric_limits +#include // char_traits +#include // tuple +#include // false_type, is_constructible, is_integral, is_same, true_type +#include // declval + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include // random_access_iterator_tag + +// #include + +// #include + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +template +struct iterator_types {}; + +template +struct iterator_types < + It, + void_t> +{ + using difference_type = typename It::difference_type; + using value_type = typename It::value_type; + using pointer = typename It::pointer; + using reference = typename It::reference; + using iterator_category = typename It::iterator_category; +}; + +// This is required as some compilers implement std::iterator_traits in a way that +// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. +template +struct iterator_traits +{ +}; + +template +struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> + : iterator_types +{ +}; + +template +struct iterator_traits::value>> +{ + using iterator_category = std::random_access_iterator_tag; + using value_type = T; + using difference_type = ptrdiff_t; + using pointer = T*; + using reference = T&; +}; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + +// #include + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN + +NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin); + +NLOHMANN_JSON_NAMESPACE_END + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN + +NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end); + +NLOHMANN_JSON_NAMESPACE_END + +// #include + +// #include + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.12.0 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann +// SPDX-License-Identifier: MIT + +#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ + #define INCLUDE_NLOHMANN_JSON_FWD_HPP_ + + #include // int64_t, uint64_t + #include // map + #include // allocator + #include // string + #include // vector + + // #include + + + /*! + @brief namespace for Niels Lohmann + @see https://github.com/nlohmann + @since version 1.0.0 + */ + NLOHMANN_JSON_NAMESPACE_BEGIN + + /*! + @brief default JSONSerializer template argument + + This serializer ignores the template arguments and uses ADL + ([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) + for serialization. + */ + template + struct adl_serializer; + + /// a class to store JSON values + /// @sa https://json.nlohmann.me/api/basic_json/ + template class ObjectType = + std::map, + template class ArrayType = std::vector, + class StringType = std::string, class BooleanType = bool, + class NumberIntegerType = std::int64_t, + class NumberUnsignedType = std::uint64_t, + class NumberFloatType = double, + template class AllocatorType = std::allocator, + template class JSONSerializer = + adl_serializer, + class BinaryType = std::vector, // cppcheck-suppress syntaxError + class CustomBaseClass = void> + class basic_json; + + /// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document + /// @sa https://json.nlohmann.me/api/json_pointer/ + template + class json_pointer; + + /*! + @brief default specialization + @sa https://json.nlohmann.me/api/json/ + */ + using json = basic_json<>; + + /// @brief a minimal map-like container that preserves insertion order + /// @sa https://json.nlohmann.me/api/ordered_map/ + template + struct ordered_map; + + /// @brief specialization that maintains the insertion order of object keys + /// @sa https://json.nlohmann.me/api/ordered_json/ + using ordered_json = basic_json; + + NLOHMANN_JSON_NAMESPACE_END + +#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ + + +NLOHMANN_JSON_NAMESPACE_BEGIN +/*! +@brief detail namespace with internal helper functions + +This namespace collects functions that should not be exposed, +implementations of some @ref basic_json methods, and meta-programming helpers. + +@since version 2.1.0 +*/ +namespace detail +{ + +///////////// +// helpers // +///////////// + +// Note to maintainers: +// +// Every trait in this file expects a non CV-qualified type. +// The only exceptions are in the 'aliases for detected' section +// (i.e. those of the form: decltype(T::member_function(std::declval()))) +// +// In this case, T has to be properly CV-qualified to constraint the function arguments +// (e.g. to_json(BasicJsonType&, const T&)) + +template struct is_basic_json : std::false_type {}; + +NLOHMANN_BASIC_JSON_TPL_DECLARATION +struct is_basic_json : std::true_type {}; + +// used by exceptions create() member functions +// true_type for pointer to possibly cv-qualified basic_json or std::nullptr_t +// false_type otherwise +template +struct is_basic_json_context : + std::integral_constant < bool, + is_basic_json::type>::type>::value + || std::is_same::value > +{}; + +////////////////////// +// json_ref helpers // +////////////////////// + +template +class json_ref; + +template +struct is_json_ref : std::false_type {}; + +template +struct is_json_ref> : std::true_type {}; + +////////////////////////// +// aliases for detected // +////////////////////////// + +template +using mapped_type_t = typename T::mapped_type; + +template +using key_type_t = typename T::key_type; + +template +using value_type_t = typename T::value_type; + +template +using difference_type_t = typename T::difference_type; + +template +using pointer_t = typename T::pointer; + +template +using reference_t = typename T::reference; + +template +using iterator_category_t = typename T::iterator_category; + +template +using to_json_function = decltype(T::to_json(std::declval()...)); + +template +using from_json_function = decltype(T::from_json(std::declval()...)); + +template +using get_template_function = decltype(std::declval().template get()); + +// trait checking if JSONSerializer::from_json(json const&, udt&) exists +template +struct has_from_json : std::false_type {}; + +// trait checking if j.get is valid +// use this trait instead of std::is_constructible or std::is_convertible, +// both rely on, or make use of implicit conversions, and thus fail when T +// has several constructors/operator= (see https://github.com/nlohmann/json/issues/958) +template +struct is_getable +{ + static constexpr bool value = is_detected::value; +}; + +template +struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> +{ + using serializer = typename BasicJsonType::template json_serializer; + + static constexpr bool value = + is_detected_exact::value; +}; + +// This trait checks if JSONSerializer::from_json(json const&) exists +// this overload is used for non-default-constructible user-defined-types +template +struct has_non_default_from_json : std::false_type {}; + +template +struct has_non_default_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> +{ + using serializer = typename BasicJsonType::template json_serializer; + + static constexpr bool value = + is_detected_exact::value; +}; + +// This trait checks if BasicJsonType::json_serializer::to_json exists +// Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion. +template +struct has_to_json : std::false_type {}; + +template +struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> +{ + using serializer = typename BasicJsonType::template json_serializer; + + static constexpr bool value = + is_detected_exact::value; +}; + +template +using detect_key_compare = typename T::key_compare; + +template +struct has_key_compare : std::integral_constant::value> {}; + +// obtains the actual object key comparator +template +struct actual_object_comparator +{ + using object_t = typename BasicJsonType::object_t; + using object_comparator_t = typename BasicJsonType::default_object_comparator_t; + using type = typename std::conditional < has_key_compare::value, + typename object_t::key_compare, object_comparator_t>::type; +}; + +template +using actual_object_comparator_t = typename actual_object_comparator::type; + +///////////////// +// char_traits // +///////////////// + +// Primary template of char_traits calls std char_traits +template +struct char_traits : std::char_traits +{}; + +// Explicitly define char traits for unsigned char since it is not standard +template<> +struct char_traits : std::char_traits +{ + using char_type = unsigned char; + using int_type = uint64_t; + + // Redefine to_int_type function + static int_type to_int_type(char_type c) noexcept + { + return static_cast(c); + } + + static char_type to_char_type(int_type i) noexcept + { + return static_cast(i); + } + + static constexpr int_type eof() noexcept + { + return static_cast(std::char_traits::eof()); + } +}; + +// Explicitly define char traits for signed char since it is not standard +template<> +struct char_traits : std::char_traits +{ + using char_type = signed char; + using int_type = uint64_t; + + // Redefine to_int_type function + static int_type to_int_type(char_type c) noexcept + { + return static_cast(c); + } + + static char_type to_char_type(int_type i) noexcept + { + return static_cast(i); + } + + static constexpr int_type eof() noexcept + { + return static_cast(std::char_traits::eof()); + } +}; + +/////////////////// +// is_ functions // +/////////////////// + +// https://en.cppreference.com/w/cpp/types/conjunction +template struct conjunction : std::true_type { }; +template struct conjunction : B { }; +template +struct conjunction +: std::conditional(B::value), conjunction, B>::type {}; + +// https://en.cppreference.com/w/cpp/types/negation +template struct negation : std::integral_constant < bool, !B::value > { }; + +// Reimplementation of is_constructible and is_default_constructible, due to them being broken for +// std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367). +// This causes compile errors in e.g. clang 3.5 or gcc 4.9. +template +struct is_default_constructible : std::is_default_constructible {}; + +template +struct is_default_constructible> + : conjunction, is_default_constructible> {}; + +template +struct is_default_constructible> + : conjunction, is_default_constructible> {}; + +template +struct is_default_constructible> + : conjunction...> {}; + +template +struct is_default_constructible> + : conjunction...> {}; + +template +struct is_constructible : std::is_constructible {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_iterator_traits : std::false_type {}; + +template +struct is_iterator_traits> +{ + private: + using traits = iterator_traits; + + public: + static constexpr auto value = + is_detected::value && + is_detected::value && + is_detected::value && + is_detected::value && + is_detected::value; +}; + +template +struct is_range +{ + private: + using t_ref = typename std::add_lvalue_reference::type; + + using iterator = detected_t; + using sentinel = detected_t; + + // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator + // and https://en.cppreference.com/w/cpp/iterator/sentinel_for + // but reimplementing these would be too much work, as a lot of other concepts are used underneath + static constexpr auto is_iterator_begin = + is_iterator_traits>::value; + + public: + static constexpr bool value = !std::is_same::value && !std::is_same::value && is_iterator_begin; +}; + +template +using iterator_t = enable_if_t::value, result_of_begin())>>; + +template +using range_value_t = value_type_t>>; + +// The following implementation of is_complete_type is taken from +// https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/ +// and is written by Xiang Fan who agreed to using it in this library. + +template +struct is_complete_type : std::false_type {}; + +template +struct is_complete_type : std::true_type {}; + +template +struct is_compatible_object_type_impl : std::false_type {}; + +template +struct is_compatible_object_type_impl < + BasicJsonType, CompatibleObjectType, + enable_if_t < is_detected::value&& + is_detected::value >> +{ + using object_t = typename BasicJsonType::object_t; + + // macOS's is_constructible does not play well with nonesuch... + static constexpr bool value = + is_constructible::value && + is_constructible::value; +}; + +template +struct is_compatible_object_type + : is_compatible_object_type_impl {}; + +template +struct is_constructible_object_type_impl : std::false_type {}; + +template +struct is_constructible_object_type_impl < + BasicJsonType, ConstructibleObjectType, + enable_if_t < is_detected::value&& + is_detected::value >> +{ + using object_t = typename BasicJsonType::object_t; + + static constexpr bool value = + (is_default_constructible::value && + (std::is_move_assignable::value || + std::is_copy_assignable::value) && + (is_constructible::value && + std::is_same < + typename object_t::mapped_type, + typename ConstructibleObjectType::mapped_type >::value)) || + (has_from_json::value || + has_non_default_from_json < + BasicJsonType, + typename ConstructibleObjectType::mapped_type >::value); +}; + +template +struct is_constructible_object_type + : is_constructible_object_type_impl {}; + +template +struct is_compatible_string_type +{ + static constexpr auto value = + is_constructible::value; +}; + +template +struct is_constructible_string_type +{ + // launder type through decltype() to fix compilation failure on ICPC +#ifdef __INTEL_COMPILER + using laundered_type = decltype(std::declval()); +#else + using laundered_type = ConstructibleStringType; +#endif + + static constexpr auto value = + conjunction < + is_constructible, + is_detected_exact>::value; +}; + +template +struct is_compatible_array_type_impl : std::false_type {}; + +template +struct is_compatible_array_type_impl < + BasicJsonType, CompatibleArrayType, + enable_if_t < + is_detected::value&& + is_iterator_traits>>::value&& +// special case for types like std::filesystem::path whose iterator's value_type are themselves +// c.f. https://github.com/nlohmann/json/pull/3073 + !std::is_same>::value >> +{ + static constexpr bool value = + is_constructible>::value; +}; + +template +struct is_compatible_array_type + : is_compatible_array_type_impl {}; + +template +struct is_constructible_array_type_impl : std::false_type {}; + +template +struct is_constructible_array_type_impl < + BasicJsonType, ConstructibleArrayType, + enable_if_t::value >> + : std::true_type {}; + +template +struct is_constructible_array_type_impl < + BasicJsonType, ConstructibleArrayType, + enable_if_t < !std::is_same::value&& + !is_compatible_string_type::value&& + is_default_constructible::value&& +(std::is_move_assignable::value || + std::is_copy_assignable::value)&& +is_detected::value&& +is_iterator_traits>>::value&& +is_detected::value&& +// special case for types like std::filesystem::path whose iterator's value_type are themselves +// c.f. https://github.com/nlohmann/json/pull/3073 +!std::is_same>::value&& +is_complete_type < +detected_t>::value >> +{ + using value_type = range_value_t; + + static constexpr bool value = + std::is_same::value || + has_from_json::value || + has_non_default_from_json < + BasicJsonType, + value_type >::value; +}; + +template +struct is_constructible_array_type + : is_constructible_array_type_impl {}; + +template +struct is_compatible_integer_type_impl : std::false_type {}; + +template +struct is_compatible_integer_type_impl < + RealIntegerType, CompatibleNumberIntegerType, + enable_if_t < std::is_integral::value&& + std::is_integral::value&& + !std::is_same::value >> +{ + // is there an assert somewhere on overflows? + using RealLimits = std::numeric_limits; + using CompatibleLimits = std::numeric_limits; + + static constexpr auto value = + is_constructible::value && + CompatibleLimits::is_integer && + RealLimits::is_signed == CompatibleLimits::is_signed; +}; + +template +struct is_compatible_integer_type + : is_compatible_integer_type_impl {}; + +template +struct is_compatible_type_impl: std::false_type {}; + +template +struct is_compatible_type_impl < + BasicJsonType, CompatibleType, + enable_if_t::value >> +{ + static constexpr bool value = + has_to_json::value; +}; + +template +struct is_compatible_type + : is_compatible_type_impl {}; + +template +struct is_constructible_tuple : std::false_type {}; + +template +struct is_constructible_tuple> : conjunction...> {}; + +template +struct is_json_iterator_of : std::false_type {}; + +template +struct is_json_iterator_of : std::true_type {}; + +template +struct is_json_iterator_of : std::true_type +{}; + +// checks if a given type T is a template specialization of Primary +template