Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

How to use STL in angelscript?


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
3 replies to this topic

#1 Rizwan Khalid   Members   -  Reputation: 122

Like
0Likes
Like

Posted 06 July 2004 - 06:50 PM

I am trying to add support of STL in angelscipt. The problem i am facing is i have to register every possible templated function.e.g. to register object of vector class engine->RegisterObjectType("vector", sizeof(vector<int>), 0); and to register push_back() engine->RegisterObjectMethod("vector", "void push_back(int)", asMETHOD(vector<int>::push_back), asCALL_THISCALL); still call to pop_back throws exception...(i think because of internal storage scheme of vector template) Is any one has use STL in his/her project or what is the method for using it? plus any support for using arrays?

Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3443

Like
0Likes
Like

Posted 07 July 2004 - 01:26 AM

As I said in the e-mail: Plans for native support for arrays in AngelScript exists for a future version.

Really, I recognize the work needed to register every possible type of array. I have some ideas for how to implement good support for arrays which ought to be quite easy to use. However it requires a lot of work and there are other things that I judge more important.

I'm not sure why your application throws an exception, it looks like you're registering the methods correctly. Maybe STL is using a calling convention other than __thiscall? Maybe you could resolve the problem with a wrapper function? Like so:


void vector_push_back(int val, vector<int> *vec)
{
vec->push_back(val);
}

engine->RegisterObjectMethod("vector", "void push_back(int)", asFUNCTION(vector_push_back), asCALL_CDECL_OBJLAST);


If it is a problem with differing calling conventions this should resolve it. Though it can be quite tedious to write the wrapper functions for all methods and types.

All I can say at the moment is that I will improve the support for this. The time for this improvement is at least 2 months away though.

I hope you will not be forced to abandon AngelScript because of this. If you should go with another scripting library, I hope you'll still keep an eye on AngelScript. You can be sure that it will improve over time.

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

#3 zola   Members   -  Reputation: 122

Like
0Likes
Like

Posted 14 July 2004 - 09:02 AM

Hi Rizwan
Have You solved Your problem with the STL vector? What have You done to solve it?

Regards
Tom

#4 Rizwan Khalid   Members   -  Reputation: 122

Like
0Likes
Like

Posted 14 July 2004 - 06:26 PM

No actually the first and the last solution came to my mind was the one that later on Andreas suggested...(make wrapper of every function and for each datatype)
So i have postponed this idea for some time..





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