Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

Registering a function that returns a reference to a paremetrized type


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Rain Dog   Members   -  Reputation: 136

Like
0Likes
Like

Posted 24 October 2004 - 09:31 PM

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]

Sponsor:

#2 paulecoyote   Members   -  Reputation: 1060

Like
0Likes
Like

Posted 24 October 2004 - 10:58 PM

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.

#3 Andreas Jonsson   Moderators   -  Reputation: 3334

Like
0Likes
Like

Posted 25 October 2004 - 02:44 AM

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

#4 Rain Dog   Members   -  Reputation: 136

Like
0Likes
Like

Posted 25 October 2004 - 08:40 AM

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.

#5 Andreas Jonsson   Moderators   -  Reputation: 3334

Like
0Likes
Like

Posted 25 October 2004 - 09:13 AM

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

#6 Rain Dog   Members   -  Reputation: 136

Like
0Likes
Like

Posted 25 October 2004 - 10:18 AM

thanks, will help immensely.

#7 Deyja   Members   -  Reputation: 920

Like
0Likes
Like

Posted 25 October 2004 - 12:49 PM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS