How to use STL in angelscript?
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?
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:
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
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
Hi Rizwan
Have You solved Your problem with the STL vector? What have You done to solve it?
Regards
Tom
Have You solved Your problem with the STL vector? What have You done to solve it?
Regards
Tom
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement