Skip to content

Replaced score::cpp with std#231

Open
marwan275 wants to merge 1 commit intoeclipse-score:mainfrom
marwan275:moma_use_std
Open

Replaced score::cpp with std#231
marwan275 wants to merge 1 commit intoeclipse-score:mainfrom
marwan275:moma_use_std

Conversation

@marwan275
Copy link
Copy Markdown

@marwan275 marwan275 commented Mar 24, 2026

Summary

Migrates mw/com tracing and skeleton event code from score::cpp types to their std equivalents, and adopts the new type-safe ServiceInstanceElement interface from baselibs.

Motivation

As part of the ongoing migration from score::cpp wrappers to standard C++ types, this PR replaces deprecated types with their std counterparts and leverages the new type-safe ServiceInstanceElement variant interface introduced in eclipse-score/baselibs@be21786. Using std::variant with distinct wrapper structs (EventId, FieldId, MethodId) instead of score::cpp::variant<uint32_t, uint32_t, uint32_t> eliminates reliance on index-based access and makes the variant type-safe.

Changes

Type migrations

Before After
score::cpp::optional<T> std::optional<T>
score::cpp::nullopt std::nullopt
score::cpp::variant (index-based) std::variant (type-safe)
ServiceInstanceElement::EventIdType (uint32_t alias) ServiceInstanceElement::EventId (struct wrapper)
ServiceInstanceElement::FieldIdType (uint32_t alias) ServiceInstanceElement::FieldId (struct wrapper)
ServiceInstanceElement::VariantType ServiceInstanceElement::StdVariantType
#include <score/optional.hpp> #include <optional>

Key code changes

  • tracing_runtime.cpp (lola): Constructs ServiceInstanceElement using the new StdVariantType constructor with EventId{}/FieldId{} struct wrappers instead of assigning raw uint32_t to aggregate members with index-based variant placement.
  • skeleton_event_binding.h: Send() signature changed from score::cpp::optional<SendTraceCallback> to std::optional<SendTraceCallback>, propagated through all implementations (lola, mock_binding) and tests.
  • common_event_tracing.h/cpp: TraceData() parameter migrated to std::optional.
  • i_binding_tracing_runtime.h / i_tracing_runtime.h: Interface methods migrated to return std::optional.
  • skeleton_event_tracing.h: Callbacks use std::optional.
  • configuration_common_resources.h / binding_service_type_deployment_impl.h: Explicit score::cpp::string_view type annotation to avoid implicit conversion issues after auto type deduction changes.
  • MODULE.bazel + examples/MODULE.bazel: Bumped score_baselibs to a93a5b3b which includes the StdVariantType constructor (commit 9c53270e).
  • BUILD files: Removed unused @score_baselibs//score/language/futurecpp:optional dependency from 3 test targets.

Dependencies

  • Requires score_baselibs at commit a93a5b3b or later (includes be21786 for type-safe structs + 9c53270e for explicit constructors).

Testing

All existing unit tests updated to use the new interface. No behavioral changes — this is a pure type migration.

@castler
Copy link
Copy Markdown
Contributor

castler commented Mar 27, 2026

Marking as draft, until basic build works.

@castler castler marked this pull request as draft March 27, 2026 15:06
@marwan275 marwan275 force-pushed the moma_use_std branch 5 times, most recently from a355a4b to 5d173d4 Compare April 10, 2026 11:49
@marwan275 marwan275 force-pushed the moma_use_std branch 8 times, most recently from 459f9f0 to c1b0a4f Compare April 17, 2026 13:29
@marwan275 marwan275 marked this pull request as ready for review April 17, 2026 13:30
Copy link
Copy Markdown
Contributor

@limdor limdor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a full reveiw yet, but some preliminary feedback.
There are too many unrelated changes in a single commit, this is not only replacing score::optional for std::optional. Please split the changes in different commits that it is easier to review and see what it is going on.

service_element_instance_identifier_view_,
trace_point_,
score::cpp::optional<TracingRuntime::TracePointDataId>{trace_point_data_id_},
std::optional<TracingRuntime::TracePointDataId>{trace_point_data_id_},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed removing the #include <score/optional.hpp> include and adding the #include <optional>

Comment thread examples/MODULE.bazel
git_override(
module_name = "score_baselibs",
commit = "69bd8297dc5de97db3362d8ea1da634883e7c27a",
commit = "a93a5b3b0a465593703834d84d6d6a64567b0307",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain why this is needed. If we need something newer we should just wait for a new release of baselibs. I do not see why we should hurry on having this change.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The baselibs bump from 69bd829 to a93a5b3b is required because this PR uses the StdVariantType constructor of ServiceInstanceElement (line 327 in tracing_runtime.cpp). At commit 69bd829, the StdVariantType alias and wrapper structs (EventId, FieldId) exist but the class has no explicit constructors — it's an aggregate. The explicit constructor accepting StdVariantType was added later in baselibs@9c53270. Without this bump, the examples integration test fails because aggregate initialization cannot convert StdVariantType (std::variant) to VariantType (score::cpp::variant) for the element_id member.

@marwan275
Copy link
Copy Markdown
Author

Replace score::cpp:: with std:: in baselibs

  • Step 1 (baselibs, merged): Introduce new type-safe wrapper structs (EventId, FieldId, MethodId) and StdVariantType alias in ServiceInstanceElement, alongside a dual constructor that accepts both VariantType (score::cpp::variant) and StdVariantType (std::variant). This was done in baselibs@be21786 and baselibs@9c53270.
  • Step 2 (this PR): Bump baselibs in communication's MODULE.bazel and migrate communication consumers to use the new std::variant/std::optional interface.
  • Step 3 (future, baselibs): Once all consumers are migrated, remove the old VariantType constructor and score::cpp::variant usage from baselibs.

- score::cpp::optional → std::optional across tracing interfaces,
  skeleton event bindings, mocks, and tests

- ServiceInstanceElement: adopt type-safe StdVariantType
  (std::variant<EventId, FieldId, MethodId>) replacing index-based
  VariantType (score::cpp::variant<uint32_t, uint32_t, uint32_t>)

- Remove unused score/optional.hpp includes and BUILD deps

- Bump score_baselibs to a93a5b3b for StdVariantType constructor
@marwan275 marwan275 changed the title replaced score::cpp with std Replaced score::cpp with std Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants