The script compiler doesn't seem to recognize any data members of a template value object.
The complier gives me these errors:
SCRIPT ERROR :: resources/_game/script/00test_init_overworld.as , row 24 , type=0 , msg='boolmember' is not a member of 'tempfailer<string>'
SCRIPT ERROR :: resources/_game/script/00test_init_overworld.as , row 25 , type=0 , msg='intmember' is not a member of 'tempfailer<string>'
class astest_tempfailer_cclass{
public:
bool boolmember;
int intmember;
astest_tempfailer_cclass(){
boolmember = 1;
intmember = 5;
}
bool Access_member_bool(){
return boolmember;
}
int Access_member_int(){
return intmember;
}
};
void astest_tempfailer_constructor_default(asIObjectType* objtype, void *memory){
new(memory)astest_tempfailer_cclass();
}
void astest_tempfailer_destructor(void *memory){
((astest_tempfailer_cclass*)memory)->~astest_tempfailer_cclass();
}
{//registration
int r = 0;
r = engine->RegisterObjectType("tempfailer<class T>", sizeof(astest_tempfailer_cclass), asOBJ_VALUE | asOBJ_TEMPLATE | asGetTypeTraits<astest_tempfailer_cclass>()); assert(r >= 0);
r = engine->RegisterObjectBehaviour("tempfailer<T>", asBEHAVE_CONSTRUCT, "void f(int&in)", asFunctionPtr(astest_tempfailer_constructor_default), asCALL_CDECL_OBJLAST); assert(r >= 0);
r = engine->RegisterObjectBehaviour("tempfailer<T>", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(astest_tempfailer_destructor), asCALL_CDECL_OBJLAST); assert(r >= 0);
r = engine->RegisterObjectProperty("tempfailer<T>", "bool boolmember", asOFFSET(astest_tempfailer_cclass, boolmember)); assert(r >= 0);
r = engine->RegisterObjectProperty("tempfailer<T>", "int intmember", asOFFSET(astest_tempfailer_cclass, intmember)); assert(r >= 0);
r = engine->RegisterObjectMethod("tempfailer<T>", "bool Access_member_bool()", asMETHOD(astest_tempfailer_cclass, Access_member_bool), asCALL_THISCALL); assert(r >= 0);
r = engine->RegisterObjectMethod("tempfailer<T>", "int Access_member_int()", asMETHOD(astest_tempfailer_cclass, Access_member_int), asCALL_THISCALL); assert(r >= 0);
}
tempfailer<string> tf;
//direct access fails
//these lines cause the compiler errors
tf.boolmember = false;
tf.intmember = 15;
//accessing with functions works fine
//correctly prints what was set in the constructor
cmPrint("tft int = " + tf.Access_member_int());
cmPrint("tft bool = " + tf.Access_member_bool());
.
I asked the script engine to enumerate the properties of objtype "tempfailer" and the properties were correctly listed there.
I just upgraded from 2.28.2 to 2.29.1, maybe theres a problem with the addons (builder?) or something, but it doesnt seem like the builder addon has been updated between these versions.
I also tried making a template specialization of a template value type (using a separate c++ class) and its members were recognized just fine.
edit: further testing indicates that template ref types also cant find their property members