Archived

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

leblebi

arrays anyone

Recommended Posts

WitchLord    4678
Not a silly question at all. You didn''t find anything about them because they are not yet supported.

I''m working on a solution for this to come out in the near future. In the meantime you can register objects with methods for accessing array elements.

Example:

struct MyArray
{
void SetLength(int numElements);
element &Item(int index);
int numElements;
element *obj;
};

Where element can be whatever type you want to store. It is not so elegant as native support for arrays, but it is a solution that works.

The reason I haven''t just added the index operator [] for pointers is that I want AngelScript to be secure, using the index operator directly would allow out-of-bounds accessing in scripts and could easily compromise security for both application and operative system.

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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
How about adding the [] operator as an overloaded one, so the program can do the bounds checking itself?

Share this post


Link to post
Share on other sites
WitchLord    4678
That is already on the list of todos. There is not much missing to add this feature. AngelScript already supports overloading for the dual operators. And adding support for the unary operators is a similar process.

Unfortunately I''m currently very short on time right now. What I was thinking was going to take a couple of days to finish is taking weeks, just because I only get a couple of hours in the weekend to work on AngelScript. This shortage on time will probably last at most until the middle of May if things go as planned.

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

Share this post


Link to post
Share on other sites