Jump to content
  • Advertisement
Sign in to follow this  
Rizwan Khalid

How to use STL in angelscript?

This topic is 5114 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 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?

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
Hi Rizwan
Have You solved Your problem with the STL vector? What have You done to solve it?

Regards
Tom

Share this post


Link to post
Share on other sites
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..

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!