Skip to content

Conversation

@marques-bruno
Copy link
Member

The toPython method in PythonFactory has 2 purposes:

  1. by looking into the Data's TypeInfo, determining which kind of data it should return: DataContainer / DataVectorString, DataString or a generic Data wrapper
  2. store the kind of data to return in a map using as key the template type of that Data, in order to not have to figure out the wrapper to return next time a similar data is to be returned

the key used for this map was BaseData::GetClass()->templateName, which happens to always be an empty string (dunno what this variable is actually supposed to store, but in the case of Data, it's alwas an empty string for me....) Thus, if a data is detected to be a "DataString" for instance, this type will be stored in a map, under the key "" (emptyString), and the next time a data must be retrieved, let's say a vector, the code will look at its templateName ("" emptyString), look into the downcast map for an existing type for this key, and return a DataString instead of a DataContainer...

This PR replaces the use of tempalteName as a key for the map, with the data's typeInfo->name(), thus effectively storing the right key in the map.

Copy link
Contributor

@jnbrunet jnbrunet left a comment

Choose a reason for hiding this comment

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

Nice find, to be merged quickly :-)

@jnbrunet jnbrunet merged commit d659b34 into sofa-framework:master Jun 9, 2020
@guparan guparan added this to the v20.12 milestone Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants