From 2ec4896578cf679d881a097516adce9bc5bb2304 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 13 Jun 2026 19:33:17 +0200 Subject: [PATCH] Split apple clipboard dispatch --- docs/modernization/debt.md | 7 ++++ docs/modernization/tasks.md | 34 +++++++++++++++++++ .../apple_platform_services.cpp | 25 ++++++++++++++ src/platform_apple/apple_platform_services.h | 2 ++ .../legacy_platform_services.cpp | 19 +++++------ 5 files changed, 77 insertions(+), 10 deletions(-) diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index db3798e..80ad1cf 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -67,6 +67,13 @@ agent or engineer to remove them without reconstructing context from chat. - 2026-06-13: `PLT-007` was narrowed again. macOS UI-state saving now routes through `src/platform_apple/apple_platform_services.*` instead of the catch-all legacy adapter; the Apple path still owns the OS-specific save call. +- 2026-06-13: `PLT-008` was narrowed again. Apple clipboard get/set now routes + through `src/platform_apple/apple_platform_services.*` instead of the + catch-all legacy adapter; the Apple path still owns the OS-specific clipboard + calls. +- 2026-06-13: `PLT-008` was narrowed again. Apple clipboard get/set now routes + through the Apple service boundary instead of the catch-all legacy adapter; + the Apple path still owns the OS-specific clipboard calls. - 2026-06-13: `DEBT-0036` was narrowed again. `NodeStrokePreview::draw_stroke_immediate()` now routes final composite execution and preview copy-back through a retained local wrapper, leaving the call site with only sequence wiring. diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index d05bfe6..5ca77f6 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -1396,6 +1396,40 @@ Completed Task Log: | --- | --- | ---: | --- | --- | | 2026-06-13 | PLT-007 | +1 platform alignment and package parity | `ctest --preset desktop-fast --build-config Debug -R pp_platform_api_tests --output-on-failure`; `cmake --build --preset windows-msvc-default --config Debug --target pp_platform_api_tests` | `623fdc67` | +### PLT-008 - Split Apple Clipboard Dispatch From Legacy Platform Adapter + +Status: Done +Score: +1 platform alignment and package parity +Debt: `DEBT-0016`, `DEBT-0017`, `DEBT-0051` +Scope: `src/platform_legacy/legacy_platform_services.cpp`, +`src/platform_apple/apple_platform_services.*` + +Goal: + +Move Apple clipboard get/set dispatch out of the catch-all legacy platform +adapter into the Apple platform service boundary. Preserve clipboard behavior +and keep non-Apple behavior unchanged. + +Done Checks: + +- `src/platform_legacy/legacy_platform_services.cpp` no longer owns the Apple + clipboard get/set branches. +- Apple clipboard get/set still dispatches through the Apple service path. +- The debt log records the reduced Apple platform tail. + +Validation: + +```powershell +ctest --preset desktop-fast --build-config Debug -R pp_platform_api_tests --output-on-failure +cmake --build --preset windows-msvc-default --config Debug --target pp_platform_api_tests +``` + +Completed Task Log: + +| Date | Task | Score | Validation | Commit | +| --- | --- | ---: | --- | --- | +| 2026-06-13 | PLT-008 | +1 platform alignment and package parity | `ctest --preset desktop-fast --build-config Debug -R pp_platform_api_tests --output-on-failure`; `cmake --build --preset windows-msvc-default --config Debug --target pp_platform_api_tests` | `pending` | + ### STR-010 - Extract Remaining Draw Merge Composite Orchestration Status: Done diff --git a/src/platform_apple/apple_platform_services.cpp b/src/platform_apple/apple_platform_services.cpp index 0244c5c..ccc32b9 100644 --- a/src/platform_apple/apple_platform_services.cpp +++ b/src/platform_apple/apple_platform_services.cpp @@ -130,6 +130,31 @@ std::string AppleDocumentPlatformServices::format_working_directory_path(std::st return std::string(path); } +std::string AppleDocumentPlatformServices::clipboard_text() const +{ + const std::string empty; +#if defined(__IOS__) + return [App::I->ios_view clipboard_get_string]; +#elif defined(__OSX__) + return [App::I->osx_view clipboard_get_string]; +#else + return empty; +#endif +} + +bool AppleDocumentPlatformServices::set_clipboard_text(std::string_view text) const +{ + const std::string value(text); +#if defined(__IOS__) + return [App::I->ios_view clipboard_set_string:value]; +#elif defined(__OSX__) + return [App::I->osx_view clipboard_set_string:value]; +#else + (void)value; + return false; +#endif +} + void AppleDocumentPlatformServices::display_file(std::string_view path) const { const std::string value(path); diff --git a/src/platform_apple/apple_platform_services.h b/src/platform_apple/apple_platform_services.h index d238b66..dd66b3a 100644 --- a/src/platform_apple/apple_platform_services.h +++ b/src/platform_apple/apple_platform_services.h @@ -35,6 +35,8 @@ public: [[nodiscard]] bool supports_working_directory_picker() const; [[nodiscard]] std::string format_working_directory_path(std::string_view path) const; + [[nodiscard]] std::string clipboard_text() const; + [[nodiscard]] bool set_clipboard_text(std::string_view text) const; void display_file(std::string_view path) const; void share_file(std::string_view path) const; void set_cursor_visible(bool visible) const; diff --git a/src/platform_legacy/legacy_platform_services.cpp b/src/platform_legacy/legacy_platform_services.cpp index 2f54764..a429996 100644 --- a/src/platform_legacy/legacy_platform_services.cpp +++ b/src/platform_legacy/legacy_platform_services.cpp @@ -249,11 +249,10 @@ public: [[nodiscard]] std::string clipboard_text() override { -#if __IOS__ - return [App::I->ios_view clipboard_get_string]; -#elif __OSX__ - return [App::I->osx_view clipboard_get_string]; -#elif __ANDROID__ + const auto family = pp::platform::current_platform_family(); + if (family == pp::platform::PlatformFamily::ios || family == pp::platform::PlatformFamily::macos) + return active_apple_document_platform_services().clipboard_text(); +#ifdef __ANDROID__ return android_get_clipboard(); #else return {}; @@ -262,14 +261,14 @@ public: [[nodiscard]] bool set_clipboard_text(std::string_view text) override { + const auto family = pp::platform::current_platform_family(); + if (family == pp::platform::PlatformFamily::ios || family == pp::platform::PlatformFamily::macos) + return active_apple_document_platform_services().set_clipboard_text(text); const std::string value(text); -#if __IOS__ - return [App::I->ios_view clipboard_set_string:value]; -#elif __OSX__ - return [App::I->osx_view clipboard_set_string:value]; -#elif __ANDROID__ +#ifdef __ANDROID__ return android_set_clipboard(value); #else + (void)value; return false; #endif }