Skip to content

mw/com/impl: Internally use memory::DataTypeSizeInfo - #813

Open
crimson11 wants to merge 2 commits into
mainfrom
mf_use_datatype_size_info
Open

mw/com/impl: Internally use memory::DataTypeSizeInfo#813
crimson11 wants to merge 2 commits into
mainfrom
mf_use_datatype_size_info

Conversation

@crimson11

Copy link
Copy Markdown
Contributor

The type DataTypeMetaInfo, which we use on our
public interface is too weak! It doesn't assure
invariants on size/alignment, which C++ demands:
size has to be always a power of two and be an
integer multiple of tzhe alignment.

This commit switches to internal use of memory::DataTypeSizeInfo which forces this. On the public interface we keep the weak DataTypeMetaInfo for now to avoid a breaking change! In the public layer we transform DataTypeMetaInfo to DataTypeSizeInfo. In case this isn't possible because DataTypeMetaInfo is invalid, we return an error in the public API.

@LittleHuba LittleHuba left a comment

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.

I'd like to discuss different approaches to this topic.
This is not a hard no, I just want to brainstorm for ideas.

@crimson11

Copy link
Copy Markdown
Contributor Author

I'd like to discuss different approaches to this topic. This is not a hard no, I just want to brainstorm for ideas.

Sure! I'm curious for your proposals! Low level I want to "extend" a type used in the public API ... and I have no clue how to do this minimal invasive - opposed to creating a NEW type and deprecate all APIs with the old type and introduce new/overloads with the new Type! In this case that would even cascade as DataTypeMetaInfo is enclosed in other public types ... so this would be a crazy escalation!

@crimson11
crimson11 force-pushed the mf_use_datatype_size_info branch 3 times, most recently from 7802866 to a0334af Compare July 31, 2026 12:54

TEST(MakeDataTypeSizeInfoTest, ConvertsValidMetaInfo)
{
RecordProperty("Description",

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.

We shouldn't have these properties if we're not linking a requirement imo. They can easily get out of sync with the code and the tests should be clear from the name and given/when/then documentation.

namespace
{

TEST(MakeDataTypeSizeInfoTest, ConvertsValidMetaInfo)

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.

ConvertsSizeMultipleOfAlignment


TEST_F(GenericSkeletonTest, CreateWithInvalidDataTypeMetaInfoAlignmentFails)
{
RecordProperty("Description",

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.

Same thing, remove recordproperty

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.

same for the other test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK!

GenericSkeletonServiceElementInfo params;
params.events = event_storage;

// The event factory must never be called for invalid meta-info

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.

Suggested change
// The event factory must never be called for invalid meta-info
// Expecting that the event factory is never be called for invalid meta-info

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.

same for the other test

{
score::mw::log::LogError("GenericSkeleton")
<< "Invalid data type meta-info provided for event: " << info.name;
return MakeUnexpected(ComErrc::kInvalidConfiguration);

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.

Should this really be an invalidConfiguration error? I associate kInvalidConfiguration with the mw_com_config. But this is an error coming from C++. And do we want to return an error here or simply terminate? Because they can only be providing a data_type_meta_info which is invalid if they are doing something weird and not simply creating with sizeof / alignof.

@crimson11 crimson11 Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

kInvalidConfiguration was the only available/existing error-code, which looked not completely "off" :)
... and the DataTypeMetaInfo can be imho sen as the configuration of a GenericSkeleton ...
I could introduce a new error code, if you really want:
kInvalidDataTypeSize ?

In this case, I would "prefer" not to terminate ... (it is always a philosophical question): This is not a somewhat internal broken state, where we can't recover from. It is a clear call/argument violation. And if you look at how GenericSkeleton is being used, it makes sense NOT to terminate! The typical users (like these data-collectors) get some info from the backend! They are not doing sizeof/alignof! If they could do sizeof/alignof, thzen there would be no need for a GenericSkeleton ... so imho terminate is too harsh here!

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.

Why is this file here and not in plumbing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good question! Will fix in a separate commit.

#ifndef SCORE_MW_COM_IMPL_PLUMBING_SKELETON_SERVICE_ELEMENT_BINDING_FACTORY_IMPL_H
#define SCORE_MW_COM_IMPL_PLUMBING_SKELETON_SERVICE_ELEMENT_BINDING_FACTORY_IMPL_H

#include "score/memory/data_type_size_info.h"

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.

The first block of includes are includes from the same package/ component, so this should be in the second block i.e. with logging

#define SCORE_MW_COM_IMPL_PLUMBING_GENERIC_SKELETON_EVENT_BINDING_FACTORY_MOCK_H

#include "score/mw/com/impl/data_type_meta_info.h"
#include "score/memory/data_type_size_info.h"

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.

The first block of includes are includes from the same package/ component, so this should be in a separate second block

Suggested change
#include "score/memory/data_type_size_info.h"
#include "score/mw/com/impl/i_generic_skeleton_event_binding_factory.h"
#include "score/memory/data_type_size_info.h"


#include "score/mw/com/impl/data_type_meta_info.h"
#include "score/memory/data_type_size_info.h"
#include "score/mw/com/impl/i_generic_skeleton_event_binding_factory.h"

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.

Suggested change
#include "score/mw/com/impl/i_generic_skeleton_event_binding_factory.h"
#include "score/mw/com/impl/i_generic_skeleton_event_binding_factory.h"
#include "score/memory/data_type_size_info.h"

#ifndef SCORE_MW_COM_IMPL_BINDINGS_LOLA_GENERIC_SKELETON_EVENT_H_
#define SCORE_MW_COM_IMPL_BINDINGS_LOLA_GENERIC_SKELETON_EVENT_H_

#include "score/memory/data_type_size_info.h"

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.

Suggested change
#include "score/memory/data_type_size_info.h"
#include "score/mw/com/impl/bindings/lola/element_fq_id.h"
#include "score/mw/com/impl/bindings/lola/event_data_storage.h"
#include "score/mw/com/impl/bindings/lola/skeleton_event_common.h"
#include "score/mw/com/impl/bindings/lola/skeleton_event_properties.h"
#include "score/mw/com/impl/generic_skeleton_event_binding.h"
#include "score/mw/com/impl/sample_allocatee_guard.h"
#include "score/memory/data_type_size_info.h"

"//score/mw/com/impl/test:dummy_instance_identifier_builder",
"//score/mw/com/impl/test:runtime_mock_guard",
"@googletest//:gtest",
"@score_baselibs//score/memory:data_type_size_info",

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.

Should now be referencing target in the com repo?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

nope. //score/memory hasn't been moved.

@crimson11
crimson11 force-pushed the mf_use_datatype_size_info branch from a0334af to ee884f0 Compare August 3, 2026 12:18
Comment thread score/mw/com/impl/bindings/lola/generic_skeleton_event.cpp Fixed
@crimson11
crimson11 force-pushed the mf_use_datatype_size_info branch from ee884f0 to 25fead2 Compare August 3, 2026 15:00
The type DataTypeMetaInfo, which we use on our
public interface is too weak! It doesn't assure
invariants on size/alignment, which C++ demands:
size has to be always a power of two and be an
integer multiple of tzhe alignment.

This commit switches to internal use of memory::DataTypeSizeInfo
which forces this. On the public interface we keep the weak
DataTypeMetaInfo for now to avoid a breaking change!
In the public layer we transform DataTypeMetaInfo to
DataTypeSizeInfo. In case this isn't possible because
DataTypeMetaInfo is invalid, we return an error in the
public API.
IGenericSkeletonEventBindingFactory has been shifted
to plumbing folder.
@crimson11
crimson11 force-pushed the mf_use_datatype_size_info branch from 25fead2 to 6e9aa5c Compare August 3, 2026 15:05
const SkeletonEventProperties& event_properties,
const ElementFqId& element_fq_id,
const DataTypeMetaInfo& size_info,
const memory::DataTypeSizeInfo& size_info,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

4 participants