Weird behaviour of property's type id

Started by
2 comments, last by noizex 2 years, 5 months ago

Hello,

I ran into strange behaviour where typeId appears to be different, depending on how I retrieve it…

engine->GetTypeInfoByName("Transform");
engine->GetTypeInfoByDecl("Transform");

both give me typeId=67108891, but at the same time, a property “Transform@ transform” which I query from it's containing class' type, when I do this:

type->GetProperty(j, &name, &property.typeId, &property.isPrivate, &property.isProtected, &property.offset, &property.isReference, nullptr, nullptr, nullptr);

the property.typeId will be different → typeId=1140850715

What's even more surprising, when I use this number and query the type by id, it returns the same instance of asITypeInfo as the ones from first block:

engine->GetTypeInfoById(property.typeId);

will give same instance as listing #1. This is problematic for me because I use GetProperty to gather properties that I later serialize, and I have mismatch of typeId between my C++ registered types depending where this id comes from - from querying via GetTypeInfoBy* or from the GetProperty…

Any idea where this mismatch comes from? Is this an error or as expected?


Where are we and when are we and who are we?
How many people in how many places at how many times?
Advertisement

It helps to look at the type ID's in hexadecimal instead of decimal:

0x0400001b
0x4400001b

The additional bit you are seeing is asTYPEID_OBJHANDLE, which makes sense as you defined it as “Transform@”. You can strip these extra bit flags by using the bitmask asTYPEID_MASK_SEQNBR: (and optionally asTYPEID_MASK_OBJECT, depending on your use case)

int baseTypeId = typeId & asTYPEID_MASK_SEQNBR;

Thanks, Miss! I suspected this could be the case, but when I did try to confirm it by retrieving typeId by decl “Transform@” I think this returned same id as for “Transform” and it confused me, making me think it shouldn't matter if it's handle or not, as the underlying type will be the same.

But it seems that indeed that's the case - I will check this again, but definitely GetProperty() returns “Transform@” type with additional flags.


Where are we and when are we and who are we?
How many people in how many places at how many times?

This topic is closed to new replies.

Advertisement