From 84e6fcc599e8af326cd5b09f557497cfdbff9d0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Sat, 19 Sep 2026 17:02:30 +0200 Subject: [PATCH] Repair MSVC enum portability (#689) --- .../native/webscene_semantic_snapshot.h | 3 ++- .../native/webscene_v8_runtime_indexeddb.inc | 4 ++-- .../native/webscene_v8_runtime_semantics.inc | 14 ++++++++------ .../tests/file_grant_ancestry_contract_tests.cpp | 5 +++-- .../tests/file_grant_directory_contract_tests.cpp | 7 ++++--- .../tests/file_grant_durable_contract_tests.cpp | 4 ++-- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_semantic_snapshot.h b/experiments/WebScene.NativeEngine.Probe/native/webscene_semantic_snapshot.h index 727f327a8..5cd28a569 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_semantic_snapshot.h +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_semantic_snapshot.h @@ -133,7 +133,8 @@ struct semantic_snapshot_data_v1 final { uint64_t top_document_generation{}; uint64_t layout_generation{}; uint32_t flags{}; - uint32_t focused_node_index{WEBSCENE_SEMANTIC_NONE_INDEX_V1}; + uint32_t focused_node_index{ + static_cast(WEBSCENE_SEMANTIC_NONE_INDEX_V1)}; std::vector documents; std::vector nodes; std::vector relationships; diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_indexeddb.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_indexeddb.inc index 105295da4..2da635354 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_indexeddb.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_indexeddb.inc @@ -286,10 +286,10 @@ : pending.locators.size(); if (pending.next_durable_index >= count) continue; const auto index = pending.next_durable_index++; - const auto action = exporting + const auto action = static_cast(exporting ? WEBSCENE_FILE_GRANT_DURABLE_EXPORT_V2 : restoring ? WEBSCENE_FILE_GRANT_DURABLE_RESTORE_V2 - : WEBSCENE_FILE_GRANT_DURABLE_REVOKE_V2; + : WEBSCENE_FILE_GRANT_DURABLE_REVOKE_V2); webscene_file_grant_durable_request_v2 request{ sizeof(request), 2U, ++next_host_request_id, action, 0U, {}, {}, {}, {}}; diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_semantics.inc b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_semantics.inc index 41fc5ad47..046250176 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_semantics.inc +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_v8_runtime_semantics.inc @@ -597,12 +597,14 @@ last_child_indices.reserve(result->nodes.capacity()); std::vector> ids; std::vector> all_id_nodes; + constexpr auto no_semantic_index = + static_cast(WEBSCENE_SEMANTIC_NONE_INDEX_V1); const auto append_document = [&](uint32_t frame_owner, uint64_t frame_generation, std::string_view origin) -> uint32_t { if (result->documents.size() == maximum_semantic_documents_v1) { result->flags |= WEBSCENE_SEMANTIC_SNAPSHOT_TRUNCATED_DOCUMENTS_V1; - return WEBSCENE_SEMANTIC_NONE_INDEX_V1; + return no_semantic_index; } webscene_semantic_document_v1 view{}; view.struct_size = sizeof(view); @@ -610,7 +612,7 @@ view.document_generation = result->top_document_generation; view.frame_generation = frame_generation; view.frame_owner_dom_node_id = frame_owner; - view.root_node_index = WEBSCENE_SEMANTIC_NONE_INDEX_V1; + view.root_node_index = no_semantic_index; view.origin = result->append_string(origin); result->documents.push_back(view); ids.emplace_back(); @@ -661,8 +663,8 @@ view.dom_node_id = node.id; view.document_index = active_document; view.parent_index = parent_index; - view.first_child_index = WEBSCENE_SEMANTIC_NONE_INDEX_V1; - view.next_sibling_index = WEBSCENE_SEMANTIC_NONE_INDEX_V1; + view.first_child_index = no_semantic_index; + view.next_sibling_index = no_semantic_index; const auto& semantic_document = result->documents[active_document]; view.semantic_id = semantic_identity( semantic_document.document_generation, @@ -689,7 +691,7 @@ node.id, view.supported_actions}); captured.push_back({&node, active_document}); - last_child_indices.push_back(WEBSCENE_SEMANTIC_NONE_INDEX_V1); + last_child_indices.push_back(no_semantic_index); if (!node.id_attribute.empty()) { ids[active_document].try_emplace(node.id_attribute, node_index); } @@ -716,7 +718,7 @@ break; } }; - visit(document.body(), top_document, WEBSCENE_SEMANTIC_NONE_INDEX_V1, false); + visit(document.body(), top_document, no_semantic_index, false); const auto subtree_text = [&](const dom_node& root) { std::string text; diff --git a/experiments/WebScene.NativeEngine.Probe/tests/file_grant_ancestry_contract_tests.cpp b/experiments/WebScene.NativeEngine.Probe/tests/file_grant_ancestry_contract_tests.cpp index c26640b0e..3cc2a5853 100644 --- a/experiments/WebScene.NativeEngine.Probe/tests/file_grant_ancestry_contract_tests.cpp +++ b/experiments/WebScene.NativeEngine.Probe/tests/file_grant_ancestry_contract_tests.cpp @@ -170,8 +170,9 @@ int main() { && current_lease->view.request_id == 100 + index, "ancestry lifecycle lease was lost"); completion_fixture result{100 + index, - index % 2 == 0 ? WEBSCENE_FILE_GRANT_ANCESTRY_SUCCESS_V2 - : WEBSCENE_FILE_GRANT_ANCESTRY_NOT_DESCENDANT_V2, + static_cast( + index % 2 == 0 ? WEBSCENE_FILE_GRANT_ANCESTRY_SUCCESS_V2 + : WEBSCENE_FILE_GRANT_ANCESTRY_NOT_DESCENDANT_V2), index % 2 == 0 ? std::vector{"child"} : std::vector{}}; require(broker.complete(result.completion), diff --git a/experiments/WebScene.NativeEngine.Probe/tests/file_grant_directory_contract_tests.cpp b/experiments/WebScene.NativeEngine.Probe/tests/file_grant_directory_contract_tests.cpp index 1c41a43ef..8f0350ab5 100644 --- a/experiments/WebScene.NativeEngine.Probe/tests/file_grant_directory_contract_tests.cpp +++ b/experiments/WebScene.NativeEngine.Probe/tests/file_grant_directory_contract_tests.cpp @@ -64,9 +64,10 @@ struct entry_fixture final { {sizeof(webscene_file_grant_metadata_v2), 2, kind == WEBSCENE_FILE_PANEL_ENTRY_FILE_V2 ? 7U : 0U, 123, kind, 0}, - kind == WEBSCENE_FILE_PANEL_ENTRY_FILE_V2 - ? WEBSCENE_FILE_PANEL_GRANT_READ_V2 - : WEBSCENE_FILE_PANEL_GRANT_ENUMERATE_V2, + static_cast( + kind == WEBSCENE_FILE_PANEL_ENTRY_FILE_V2 + ? WEBSCENE_FILE_PANEL_GRANT_READ_V2 + : WEBSCENE_FILE_PANEL_GRANT_ENUMERATE_V2), 0, {name.data(), name.size()}, {grant.data(), grant.size()}}; } }; diff --git a/experiments/WebScene.NativeEngine.Probe/tests/file_grant_durable_contract_tests.cpp b/experiments/WebScene.NativeEngine.Probe/tests/file_grant_durable_contract_tests.cpp index 1fd49242a..401d13fdb 100644 --- a/experiments/WebScene.NativeEngine.Probe/tests/file_grant_durable_contract_tests.cpp +++ b/experiments/WebScene.NativeEngine.Probe/tests/file_grant_durable_contract_tests.cpp @@ -135,10 +135,10 @@ int main() { const auto resident_before = resident_bytes(); const auto started = std::chrono::steady_clock::now(); for (std::uint64_t index = 0; index < cycles; ++index) { - const auto action = index % 3 == 0 + const auto action = static_cast(index % 3 == 0 ? WEBSCENE_FILE_GRANT_DURABLE_EXPORT_V2 : index % 3 == 1 ? WEBSCENE_FILE_GRANT_DURABLE_RESTORE_V2 - : WEBSCENE_FILE_GRANT_DURABLE_REVOKE_V2; + : WEBSCENE_FILE_GRANT_DURABLE_REVOKE_V2); request_fixture current{100 + index, action}; require(broker.queue(current.request, [&](file_grant_durable_completion_data_v2&&) { ++callbacks; }),