A question about AngelScript
Heya :)
First of all, nice engine you have here. Congrats. ^_^
A few words why am I here... after having realized I need to overhaul my scripting engine (I ended up with a totally messy syntax lol) I was wondering wheter to simply just throw it out and use something already up to the job. So I got to Angelscript and very liked some of the features (especially the fact I don't have to mess around with proxy functions).
Now my question might be totally stupid for seasoned AS users, if so, sorry about in advance.
How does AS stand with stl containers? My code makes pretty heavy use of them (namely, of std::vector, std::string, std::map, stdext::hash_map, std::multimap and std::deque), so it's pretty important to nicely handle them. Now, I have alredy seen the std::vector implementation class for AS, so I figure at least that one works =) but I wondered what about the rest - I mean, I would have to make wrappers for those, or is there some way to handle them more lazyly?
The STL containers doesn't have a native reference counter, so they are not ideal for AngelScript. But with a little work (and I mean a little) you should be able to get them to work just fine.
I suggest you take a look at how asCScriptString (in add_on/scriptstring) is implemented. This is a very light wrapper on the std::string class that adds reference counting so that object handles can be used with the string type. Only very few of the std::string methods needs to be wrapped.
It might even be possible to use shared_ptr<> or something similar as the wrapper of the STL container.
Of course, if you don't want the containers to support object handles, then you could register them just like the code in stdvector.h does it. It wouldn't be very effective though, as objects without support for handles are copied a lot when passed around.
Regards,
Andreas
I suggest you take a look at how asCScriptString (in add_on/scriptstring) is implemented. This is a very light wrapper on the std::string class that adds reference counting so that object handles can be used with the string type. Only very few of the std::string methods needs to be wrapped.
It might even be possible to use shared_ptr<> or something similar as the wrapper of the STL container.
Of course, if you don't want the containers to support object handles, then you could register them just like the code in stdvector.h does it. It wouldn't be very effective though, as objects without support for handles are copied a lot when passed around.
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement