Archived

This topic is now archived and is closed to further replies.

Arrays / Indexing operators ?

This topic is 4959 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 just started using all the nifty operator-stuff, but there''s one thing I could really *really* use : a way to use arrays in script, or in case that''s not possible some way to use indexing-operators so I could create my own array-like-thingie. I know I''ve been bugging Andreas about this for a long time, and I understand the problems this might cause, but still.. it would make my life a whole lot easier Any thoughts / future plans on this ..?

Share this post


Link to post
Share on other sites
Actually the code is pretty much prepared already for adding support for the indexing operator, but alas I don''t have the time to finish it.

Native support for arrays are more complicated, and I will not work on that for a while yet. But I plan to support it one day.

If you (or someone else) are interested in adding the support for the indexing operator yourself maybe I can walk you through it. There should be relatively few things that needs to be done.

1. Add a new flag for the RegisterOperator()
2. Treat the flag
3. Add the [ and ] tokens
4. Add parsing of the indexing operator
5. Compile the indexing operator in CompilePostOperator (Much of the code from CompileFunctionCall() can be reused.)

Until the indexing operator is done, I suggest you register an object method. The actual C++ function used for registering the overloaded [] operator will be the same anyway.

__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library - Tower - free puzzle game

Share this post


Link to post
Share on other sites
Point taken

I''ve just finished my preliminary array support,
it''s templatized so I just need to call gRegisterArray(engine, "Vertex") (or Vector2, or whatever) and everything should instantly work.

Or so I hope

Share this post


Link to post
Share on other sites