You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is the situation. I have an Engine library (DLL) where I try to reflect the std::vector class.
I wanted to use this reflected vector in a Scripting dll driven by an Editor application. (Manipulate and display the vector content in an inspector).
The problem is that when I'm trying to declare one in the Scripting dll, double registration warnings show up.
// STDTemplateClass used as a global instance for all standard template classestemplate <typename Type>
classHY_CLASS() HyVector final : public STDTemplateClass, public std::vector<Type>
{
public:HY_METHOD() std::size_tsize();
HY_METHOD() void* GetElementAt(std::size_tindex);
HY_METHOD() void* AddNewElement();
HyVector_GENERATED
};
This drives to another problem. When I'm trying to retrieve some methods from the class template instantiation given by the field archetype, methods are not found and are set to null. I bypassed this problem by retrieving the base archetype on the database from the field archetype ID.
// From field archetype
rfk::Archetype const* fieldArchetype = field.getType().getArchetype();
rfk::ClassTemplateInstantiation const* cTempInstance = rfk::classTemplateInstantiationCast(fieldArchetype );
// Retrieve vector instance
STDTemplateClass& vecClass = *reinterpret_cast<STDTemplateClass*>(field.getPtr(owner));
// Here, the getMethod is not valid
rfk::Method const* getMethod = cTempInstance->getMethodByName("GetElementAt");
// From field archetype ID
fieldArchetype = rfk::getDatabase().getClassById(fieldArchetype ->getId());
cTempInstance = rfk::classTemplateInstantiationCast(fieldArchetype);
// Here, the getMethod is valid and usable
getMethod = cTempInstance->getMethodByName("GetElementAt");
The text was updated successfully, but these errors were encountered:
I indeed forgot to consider the case the same template is used in different translations units leading at a duplication of the same archetype...
It doesn't seem trivial to fix either, I'll need a bit of time to find an elegant solution to fix this problem. Off the top of my head, I don't understand why the archetype duplicate doesn't contain the reflected method neither.
The workaround is almost performance-free so I recommand people having this issue to use it until the bug is fixed.
Here is the situation. I have an Engine library (DLL) where I try to reflect the std::vector class.
I wanted to use this reflected vector in a Scripting dll driven by an Editor application. (Manipulate and display the vector content in an inspector).
The problem is that when I'm trying to declare one in the Scripting dll, double registration warnings show up.
Here is the vector class :
This drives to another problem. When I'm trying to retrieve some methods from the class template instantiation given by the field archetype, methods are not found and are set to null. I bypassed this problem by retrieving the base archetype on the database from the field archetype ID.
The text was updated successfully, but these errors were encountered: