Sign in to follow this  

Template value type members not recognized

Recommended Posts

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/ , row 24 , type=0 , msg='boolmember' is not a member of 'tempfailer<string>'
SCRIPT ERROR :: resources/_game/script/ , row 25 , type=0 , msg='intmember' is not a member of 'tempfailer<string>'
The problem can be reproduced with this cpp code:
class astest_tempfailer_cclass{
  bool boolmember;
  int intmember;

    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){
void astest_tempfailer_destructor(void *memory){

  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);


and this as code:
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

Edited by Samichama

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this