Registering a function that returns a reference to a paremetrized type
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]
it would probably simplify things for you and the compiler if you typedef'd your vector of vectors.
Or even typedef'd your int vector, then used it in your other vector.
Or even typedef'd your int vector, then used it in your other vector.
Could you explain the problem? It's difficult to help if you don't tell us what problem you are experiencing.
I get an "invalid configuration" error when i attempt to register these functions:
The calling code is formulated as so:
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);
All of the commented out sections cause the registration in the previous listed sections to fail.
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);
All of the commented out sections cause the registration in the previous listed sections to fail.
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]
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]
I should have clarified myself, but I'm glad WL understands my code well enough to answer that question already. :D
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement