Sign in to follow this  

Registering a function that returns a reference to a paremetrized type

This topic is 4832 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

I am trying to register a vector< vector<int> > object using deyja's new vector registration code and it appears to work fine except when i register a vector of vectors. The problem occurs when the code attempts to register with the script engine a method or function that takes as a parameter or returns as a result a object of type [vector of vectors]

Share this post


Link to post
Share on other sites
I get an "invalid configuration" error when i attempt to register these functions:

error_code = engine->RegisterObjectBehaviour(V_AS.c_str(),
asBEHAVE_INDEX,
(T_AS+"& f(int)").c_str(),
asFUNCTION(vectorRegisterHelper<T>::Index),
asCALL_CDECL_OBJLAST);
assert(error_code == 0 && "Failed to register operator[]");



and this one:
error_code = engine->RegisterObjectMethod(V_AS.c_str(),
(std::string("void push_back(const ")+T_AS+"&)").c_str(),
asFUNCTION(vectorRegisterHelper< T >::PushBack),
asCALL_CDECL_OBJLAST);
assert(error_code == 0 && "Failed to register push_back");



The calling code is formulated as so:


RegisterVector<int>("IntArray" , "int" , engine);
//RegisterVector< vector<int> >("IntArrayArray" , "vector<int>" , engine);

RegisterVector<int>("IntArray" , "int" , engine);
//RegisterVector< vector<int> >("IntArrayArray" , "vector<int>" , engine);
RegisterVector<float>("FloatArray", "float", engine);
//RegisterVector< vector<float> >("FloatArrayArray" , "vector<float>" , engine);
RegisterVector<double>("DoubleArray", "double", engine);
//RegisterVector< vector<double> >("DoubleArrayArray" , "vector<double>" , engine);
//RegisterVector<long>("LongArray", "long", engine);
//RegisterVector< vector<long> >("LongArrayArray" , "vector<long>" , engine);
RegisterVector<string>("StringArray", "string", engine);
//RegisterVector< vector<string> >("StringArrayArray" , "vector<string>" , engine);
[/code]


All of the commented out sections cause the registration in the previous listed sections to fail.

Share this post


Link to post
Share on other sites
The problem lies with the second parameter passed to RegisterVector().

The second array contains objects of IntArray, not vector<int>.

RegisterVector<int>("IntArray" , "int" , engine);
RegisterVector< vector<int> >("IntArrayArray", "IntArray", engine);

Hope that helps [smile]

Share this post


Link to post
Share on other sites
I should have clarified myself, but I'm glad WL understands my code well enough to answer that question already. :D

Share this post


Link to post
Share on other sites
Sign in to follow this