🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Insight on registering Iterators

Started by
2 comments, last by WitchLord 19 years, 3 months ago
Any insight in registering templated iterators? such as vector<int>::iterator etc etc.
Advertisement
Although possible to register the std::iterators, I do not recommend it, because they are not safe in a scripted environment. This is because the iterator doesn't verify if the container is valid. It simply assumes the programmer knows what he's doing (which is not always the case for script writers).

Correct me if I'm wrong.

In either case, you'd have to register a new type for each of the iterators you wish to use, and the appropriate methods to work with them. The increment and decrement operators are not overloadable for AngelScript (yet anyway) so you'd have to settle for methods like next() and prev().

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

But as an script engine is like a front-end for the underlaying engine, you can implement safety checks in the AS iterator assigment functions, like testing for it != iend and (*it) or it->second != NULL

assigment operators functions can be registerd in AS, right?

Or an interator factory can be registered in AS

All refers to AS 1.x, i have never used AS 2.x

Lioric
Yes, assignment operators can be registered.

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