Jump to content
  • Advertisement
Sign in to follow this  
Samichama

Template value type members not recognized

This topic is 1474 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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/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>'
 
The problem can be reproduced with this cpp code:
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);
}

 

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!