Registering a function that returns a reference to a paremetrized type

Started by
5 comments, last by Deyja 19 years, 5 months ago
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]
Advertisement
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.
Anything posted is personal opinion which does not in anyway reflect or represent my employer. Any code and opinion is expressed “as is” and used at your own risk – it does not constitute a legal relationship of any kind.
Could you explain the problem? It's difficult to help if you don't tell us what problem you are experiencing.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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



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]

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

thanks, will help immensely.
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